在我的网站上,当我点击一个按钮时,我必须启动谷歌地图,用于驾驶方向。我知道终点,但我必须告诉起点,那是我的位置,与地理位置。我对智能手机的地理定位有问题。这是我的密码:
jQuery(window).load(function(){ if (navigator.geolocation) navigator.geolocation.getCurrentPosition(function(position){ myLat=position.coords.latitude; myLng=position.coords.longitude; jQuery(".btn").attr("href", "http://www.google.it/maps?saddr="+myLat+","+myLng+"&daddr=44.000000,7.000000")}; }); });
它在pc上运行得很好,但在智能手机上却不能运行。发生了错误。我应该为这些设备编写不同的href吗?如果是的话,怎么做?非常感谢你的帮助!
发布于 2016-03-03 11:15:01
我想我解决了。我检测到我是否在使用移动设备,对于它们,我使用以下代码
if( isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()){
jQuery(".btn").attr("href", "https://maps.google.com?saddr=Current+Location&daddr=44.000000,7.000000")
}谢谢你的支持,里卡多
发布于 2016-03-03 10:27:44
如果它能在某种程度上对你有帮助的话。geolocation.asp
https://stackoverflow.com/questions/35767451
复制相似问题