<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="format-detection" content="telephone=no,email=no,adress=no" />
<title>无标题文档</title>
<style>#map_canvas{width:300px; height:300px; margin:20px;}</style>
<script type="text/javascript" src="//api.map.sogou.com/maps/js/api_v2.5.1.js"></script>
</head>
<script>
window.onload = function() {
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var myLatlng = new sogou.maps.LatLng(position.coords.latitude,position.coords.longitude);
var myOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: sogou.maps.MapTypeId.ROADMAP
}
var map = new sogou.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new sogou.maps.Marker({
position: myLatlng,
map: map,
title:"我在这里!"
});
},
function(error){
var errorTypes = {
1:'位置服务被拒绝,请打开获取位置的权限',
2:'获取不到位置信息,请打开设备定位服务',
3:'获取信息超时'
};
document.getElementById("geo_loc").innerHTML = errorTypes[error.code];
});
}else{
document.getElementById("geo_loc").innerHTML = "您当前使用的浏览器不支持HTML5 Geolocation服务";
}
}
</script>
<body>
<div align="center">
<div id="map_canvas"></div>
<div id="geo_loc"></div>
</div>
</body>
</html>