如何在 google 地图 api V3 中将图像锚点居中?

发布于 2024-11-15 23:37:23 字数 842 浏览 2 评论 0原文

我试图将 google 地图 api 此处 中的图标锚点居中,但是当我尝试时直到爆炸图像消失。

此代码工作正常,但锚点位于图像的底部中心:

  var image_explode = 'images/map/explode.png';
  var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
  var explode = new google.maps.Marker({
      position: explode_longlat,
      map: map,
      icon: image_explode
  });

我尝试使用此代码使锚点居中,但它消失了:

  var image_explode = new google.maps.MarkerImage("projectstratos.com/images/map/explode.png",new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(10,10));
  var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
  var explode = new google.maps.Marker({
      position: explode_longlat,
      map: map,
      icon: image_explode
  });

I'm trying to center the anchor of an icon in the google maps api here but when I try to the explosion image disapears.

This code works fine but the anchor is at the bottom center of the image:

  var image_explode = 'images/map/explode.png';
  var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
  var explode = new google.maps.Marker({
      position: explode_longlat,
      map: map,
      icon: image_explode
  });

I tried making the anchor centered using this code but it dissapears:

  var image_explode = new google.maps.MarkerImage("projectstratos.com/images/map/explode.png",new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(10,10));
  var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
  var explode = new google.maps.Marker({
      position: explode_longlat,
      map: map,
      icon: image_explode
  });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一笑 2024-11-22 23:37:23

如果要包含主机名,则需要在 URL 中使用方案 (http://):

  var explode_image = new google.maps.MarkerImage("http://projectstratos.com/images/map/explode.png", new google.maps.Size(20,20), new google.maps.Point(0,0), new google.maps.Point(10,10));
  var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
  var explode = new google.maps.Marker({
      position: explode_longlat,
      map: map,
      icon: explode_image
  });

或者,将主机名 (projectstratos.com) 保留为关闭。

You need the scheme (http://) in your URL if you are going to include the hostname:

  var explode_image = new google.maps.MarkerImage("http://projectstratos.com/images/map/explode.png", new google.maps.Size(20,20), new google.maps.Point(0,0), new google.maps.Point(10,10));
  var explode_longlat = new google.maps.LatLng(-18.142599, 178.431);
  var explode = new google.maps.Marker({
      position: explode_longlat,
      map: map,
      icon: explode_image
  });

Alternatively, leave the hostname (projectstratos.com) off.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文