临沂php吧 关注:8贴子:55
  • 0回复贴,共1

调用百度地图

只看楼主收藏回复

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width = device-width; initial-scale=1">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function startgps()
{
var gps = navigator.geolocation;
if (gps)
{
gps.getCurrentPosition(showgps,
function(error)
{
alert("Got an error, code: " + error.code + " message: "
+ error.message);
},
{
maximumAge : 10000
}); // 这里设置超时为10000毫秒,即10秒
}
else
{
showgps();
}
}
function showgps(position)
{
if (position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
//alert("latitude: " + latitude + "\r\n longitude: " + longitude);
location.href="http://api.map.baidu.com/marker?location="+latitude+","+longitude+"&title=我的位置&content=百度奎科大厦&output=html&src=yourComponyName"
}
else
alert("position is null");
}
</script>
<body>
<input type="button" onclick="startgps()" value="提交" />
</body>
</html>


1楼2015-03-10 08:57回复