我主要使用PHP代码,我没有丰富的JavaScript范围知识;希望有人能很快解决我的问题。如评论所示,检查mapCenter.Latitude和mapCenter.Longitude - 它们显示为空。firefox位置感知+ javascript范围
如果将执行,如果位置感知在浏览器中可用 - 我敢肯定它适用于我,我用alert()测试它。此外,我知道它正确地抓住position.coords.latitude/longitude,因为我用alert()的方法测试了这些...但是这些值在函数之外并不是持久的。这可能是微不足道的 - 解决方法是什么?
function load(){
map = new VEMap('MapDiv');
map.LoadMap();
mapCenter = new VELatLong();
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(position)
{
mapCenter.Latitude = position.coords.latitude;
mapCenter.Longitude = position.coords.longitude;
});
}
//Inspecting mapCenter.Latitude & mapCenter.Longitude shows empty...
map.SetCenterAndZoom(mapCenter, 15);
...
...
}
谢谢!
这是完美的,谢谢你的代码,和优秀的解释。干杯! – 2011-05-25 22:14:22