当前位置:首页 > 教程

HTML5地理定位功能 如何在地图中显示结果

来源:http://h5uc.92game.net 作者:92game 时间:2016-05-17 22:36:39

导读:HTML5 Geolocation(地理定位)用于定位用户的位置,本文小编为您详解HTML5地理定位功能 如何在地图中显示结果!

如需在地图中显示结果,您需要访问可使用经纬度的地图服务,比如谷歌地图或百度地图:

实例

function showPosition(position)
{
var latlon=position.coords.latitude+","+position.coords.longitude;

var img_url="http://maps.googleapis.com/maps/api/staticmap?center="
+latlon+"&zoom=14&size=400x300&sensor=false";

document.getElementById("mapholder").innerHTML="<img src='"+img_url+"' />";
}

在上例中,我们使用返回的经纬度数据在谷歌地图中显示位置(使用静态图像)。


核弹头小游戏网发布此文仅为传递信息,不代表认同其观点或者证实其描述!

游戏集合

男生最爱
儿童节专题

Copyright © 2011-2016 92game. All rights reserved. 天津畅玩网络科技有限公司

津网文〔2015〕1158-004号 津ICP备15003662号