【问题标题】:How do I center an image anchor in google maps api V3?如何在谷歌地图 api V3 中居中图像锚点?
【发布时间】:2011-06-19 02:10:58
【问题描述】:

我试图在谷歌地图 api here 中将图标的锚点居中,但是当我尝试爆炸图像消失时。

此代码运行良好,但锚点位于图像的底部中心:

  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
  });

【问题讨论】:

    标签: javascript google-maps google-maps-api-3 anchor center


    【解决方案1】:

    如果要包含主机名,则需要在 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)。

    【讨论】:

    • 非常感谢!!你能告诉我你做错了什么吗?
    猜你喜欢
    • 1970-01-01
    • 2012-05-26
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-28
    相关资源
    最近更新 更多