2

我在我的网站中嵌入了谷歌地图,但我希望能够将信息气泡中的名称更改为除“地址”之外的名称,例如,我想更改信息气泡中的“地址”点击链接,使其显示“聪明的人在这里工作”

<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>
4

2 回答 2

0

据我所知,您必须构建自己的 JavaScript 页面才能更改该气泡。它只使用基本的 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>
于 2012-05-23T22:59:48.070 回答
0

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

于 2016-02-23T16:59:31.780 回答