更改嵌入式Google地图信息气泡中的位置名称

时间:2012-05-23 21:08:13

标签: google-maps google-maps-markers

我在我的网站中嵌入了Google地图,但我希望能够将信息泡泡中的名称更改为“地址”以外的名称,例如我想更改信息中的“地址”在以下链接中冒泡,以便说“聪明人在这里工作”

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=One+Exchange+Plaza,+26th+Floor+New+York,+NY+10006&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=39.371738,86.572266&amp;ie=UTF8&amp;hq=&amp;hnear=1+Exchange+Plaza,+New+York,+10006&amp;t=m&amp;z=14&amp;ll=40.706793,-74.012592&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=One+Exchange+Plaza,+26th+Floor+New+York,+NY+10006&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=39.371738,86.572266&amp;ie=UTF8&amp;hq=&amp;hnear=1+Exchange+Plaza,+New+York,+10006&amp;t=m&amp;z=14&amp;ll=40.706793,-74.012592" style="color:#0000FF;text-align:left">View Larger Map</a></small>

2 个答案:

答案 0 :(得分:0)

据我所知you have to build your own JavaScript page来改变这种泡沫。它只使用基本的API组件,但我认为单个标记非常麻烦。它的优点是可高度定制。我只是试图复制原文,省略方向和搜索链接。

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      html, body { margin: 0; padding: 0; height: 100% }
      #infoContents { color: blue; font-family: Arial, sans-serif; font-size: 12px }
    </style>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
      var map;
      var spot = new google.maps.LatLng(40.706793,-74.012592);
      var mapCenter = new google.maps.LatLng(40.712583,-74.00933592);
      var mapOptions = { center: mapCenter, zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP };

      function initialize() {
        map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        var iconShadow = new google.maps.MarkerImage(
          "http://www.google.com/mapfiles/ms/micons/msmarker.shadow.png", 
          new google.maps.Size(59,32),
          new google.maps.Point(0,0),
          new google.maps.Point(15,32));

        var marker = new google.maps.Marker({
          map: map,
          position: spot,
          icon: "http://www.google.com/mapfiles/markerA.png",
          shadow: iconShadow
        });

        var infowindow = new google.maps.InfoWindow({
          content: '<div id="infoContents"><b style="font-size: 16px">I am so Smart</b><br><br>1 Exchange Plaza<br>New York, NY 10006</div>'
        });

        infowindow.open(map, marker);
      }

      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map_canvas" style="width: 425px; height: 350px;"></div>
  </body>
</html>

答案 1 :(得分:0)

如果您在2016年阅读此内容,则可以使用Google MyMaps创建地图并节省时间;)