0

我一直在浏览 google api,但一直无法找到有关如何进行标记导航的信息。例如http://maps.google.com/maps/ms?msid=214364913744716823698.00046c8f8a60625db2c21&msa=0&ll=48.068903,-91.109619&spn=0.537763,0.883026

我用三个标记制作了这张地图,我想把它嵌入到我的网站中,然后有三个与标记匹配的链接,当你点击链接时,它会将地图平移到那个制造商。是否可以使用保存的谷歌地图来做到这一点?

4

1 回答 1

0

Here is a complete example. Basically, the map.setCenter command will allow you to move from one point to another

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
  <title>Demo</title> 
  <script src="http://maps.google.com/maps/api/js?sensor=false" 
          type="text/javascript"></script>
</head> 
<body>
  <div> 
     <a href="#" onclick="map.setCenter(a);">Point A</a> 
     <a href="#" onclick="map.setCenter(b);">Point B</a>
     <a href="#" onclick="map.setCenter(c);">Point C</a>
  </div>
  <div id="map" style="width: 640px; height: 480px;"></div>

  <script type="text/javascript">
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 9,
      center: new google.maps.LatLng(40.00, -104.00),
      mapTypeId: google.maps.MapTypeId.TERRAIN
    });

    var a = new google.maps.LatLng(40.00, -104.00);
    var b = new google.maps.LatLng(41.00, -105.00);
    var c = new google.maps.LatLng(39.00, -103.00);

    new google.maps.Marker({
        position: a,
        map: map
    });

    new google.maps.Marker({
        position: b,
        map: map
    });

    new google.maps.Marker({
        position: c,
        map: map
    });  
  </script>
</body>
</html>
于 2012-05-18T21:33:58.403 回答