谷歌地图API pan up onload

时间:2012-10-03 10:35:27

标签: google-maps-api-3

无法相信没有一个简单的答案,需要这张地图自动平移或停止信息窗口从地图顶部消失的其他方式...

http://www.triangledesign.biz/contact-dev.php

...代码

    var mapOptions = {
      center: new google.maps.LatLng(51.539104, -2.400264),
      zoom: 16,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

    var image = 'cup-sm.png';
    var myLatLng = new google.maps.LatLng(51.539104, -2.400264);
    var contentString = '<div id = "info-window">';
        contentString += '<div class = "float-left"><h1>Get in touch</h1></div>';
        contentString += '<div class ="divider4"><!--div--></div>';
        contentString += '<div class = "float-left">';
            contentString += 'Riverside House,<br>Quarry Road,<br>Chipping Sodbury,<br>Bristol BS37 6AX,<br>United Kingdom';
        contentString += '</div>';
        contentString += '<div class ="divider4"><!--div--></div>';
        contentString += '<div class = "float-left">';
            contentString += '<span class = "grey">t&nbsp;+44 (0)1454 311 220</span><br><a href ="mailto:info@triangledesign.biz" class = "grey">info@triangledesign.biz</a>';
        contentString += '</div>';
    contentString += '</div>';

    var image = new google.maps.MarkerImage("cup-sm.png",
    // This marker is 20 pixels wide by 32 pixels tall.
    null, 
    // The origin for this image is 0,0.
    new google.maps.Point(0,0)
    // The anchor for this image is the base of the flagpole at 0,32.

);


    var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          title:"Get In Touch",
          icon: image
      });

    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });

    $(document).ready(function(){
      infowindow.open(map,marker);
    });

1 个答案:

答案 0 :(得分:1)

好吧,只需在变量 myOptions 上更改属性center中的纬度。

将中心稍微设置在南侧。

我认为没有其他解决方案,因为信息窗口大于地图的一半。