谷歌可以从标记中点击可点击的信息窗口

时间:2013-07-11 11:06:15

标签: javascript google-maps google-api infowindow

我有来自谷歌地图标记的链接的脚本:

<script type="text/javascript">

  var locations = [['Test 1','55','13','url1'],['Test 2','45','17','url2']];

  function initialize()
    {
    var myOptions = {
        center: new google.maps.LatLng(50,15),
        zoom: 3,
        mapTypeId: google.maps.MapTypeId.SATELLITE};

    var map = new google.maps.Map(document.getElementById("map"),myOptions);

    setMarkers(map,locations)
    }

  function setMarkers(map,locations)
    {
    var marker, i

    for(i = 0; i < locations.length; i++)
      {
      var arr = i
      var name = locations[i][0]
      var lat = locations[i][1]
      var long = locations[i][2]
      var adress = locations[i][3]

      latlngset = new google.maps.LatLng(lat, long);

      var marker = new google.maps.Marker({
            map: map,
            title: name,
            url: adress,
            position: latlngset  
          });

      google.maps.event.addListener(marker, 'click', function() {window.location.href = this.url;});
      }
    }

  google.maps.event.addDomListener(window, 'load', initialize);

  </script>

...而且,我需要从标记而不是链接生成信息窗口,你有什么简单的想法吗?

Google地图可点击的标记信息

0 个答案:

没有答案