0
不能相信這個問題沒有一個簡單的答案,需要這個地圖自動地平移或以某種方式阻止信息窗口消失在地圖的頂端之外......Google maps API pan up
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 +44 (0)1454 311 220</span><br><a href ="mailto:[email protected]" class = "grey">[email protected]</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);
});
然後標記將出現在錯誤的地方。沮喪這不是一個簡單的變量選項。 – user1413808
@ user1413808不,您不會更改標記座標,只是mapOptions中的地圖中心,而不是myLatLng中的地圖中心。 –
對不起有點模糊,只是意識到你的意思,謝謝。只是意識到地圖中心和標記協調可能不同,仍然涉及去谷歌地圖找到北部的地方,然後使用緯度。 – user1413808