如何插入交互式地图?

时间:2012-07-01 04:33:19

标签: javascript jquery google-maps google-maps-api-3

我正在尝试在我的网站中使用GoogleMap:

           function InsertMap()
           {
               var map;
                var op = {
                    zoom: 10,
                    center: new google.maps.LatLng(-34.397, 150.644),
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };                    
                map = new google.maps.Map(document.getElementById('id'), op);
           }

我在按钮点击事件上调用此函数。但我的问题是它插入一个静态地图(单个图像)而不是交互式地图。我也尝试了IsStaticMap : false,但它不起作用,当我这样做时,它既没有静态也没有交互。救救我!

2 个答案:

答案 0 :(得分:0)

有一个使用jQuery的实现可能对你有帮助。包含源代码和演示!

http://www.position-absolute.com/articles/create-an-interactive-google-map-widget-with-a-list-filter-and-a-map-helper-class/

答案 1 :(得分:-1)

这是我通常使用的,效果很好!您可以根据自己的要求进行编辑。     

  <iframe
    width="425"
    height="350"
    frameborder="0"
    scrolling="no"
    marginheight="0"
    marginwidth="0"
    src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=San%2BFrancisco%2C%2BCalifornia(HEY%21)@37.774930,-122.419416&ie=UTF8&z=12&t=m&iwloc=addr&output=embed">
  </iframe>

<br>

<table
  width="425"
  cellpadding="0"
  cellspacing="0"
  border="0">
  <tr>
    <td align="left">
      <small><a href="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=San%2BFrancisco%2C%2BCalifornia(HEY%21)@37.774930,-122.419416&ie=UTF8&z=12&t=m&iwloc=addr">View Larger Map</a></small></td><td align="right"><small><a href="http://www.github.com/dtx">my git!</a></small></td></tr>
</table>
</div>

DEMO HERE