1
在谷歌地圖API V3,以下行的工作:Google Maps API v3的一個非常奇怪的錯誤?
var myLatlng = new google.maps.LatLng(50.082243,24.302628);
但是,下列情況不:
var gpsPos = '50.082243,24.302628';
var myLatlng = new google.maps.LatLng(gpsPos);
多麼奇怪的是,或者更好的是,如何解決這一問題?
下面是完整的代碼:
$("document").ready(function(){
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false®ion=SK&callback=initialize";
document.body.appendChild(script);
});
function initialize(){
var gpsPos = '50.082243,24.302628';
var myLatlng = new google.maps.LatLng(gpsPos);
var myOptions = {
zoom: 7,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: false,
zoomControl: true,
mapTypeControl: true,
scaleControl: false,
streetViewControl: false,
scrollwheel: false
}
var map = new google.maps.Map(document.getElementById("otvorena-aukcia-mapa"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map
});
}
'50.082243,24.302628'是兩個浮點數,''50 .082243,24.302628''是一個字符串。這真的有用嗎? – TLP