Google map api v3我在网页上能正常显示,到安卓手机上怎么显示不了呢?即求助

棠棠 发布于 2012/03/09 11:11
阅读 2K+
收藏 0
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>派昂智能PC终端</title>
<link href="css/style.css" rel="stylesheet" type="text/css">

<script src="../js/jquery-1.6.4.js" type="text/javascript"></script>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>

<script type="text/javascript">

var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var browserSupportFlag = new Boolean();
var map;
var infowindow = new google.maps.InfoWindow();


var latitude;
var longitude;


function initialize() {
var myOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);


// Try W3C Geolocation method (Preferred)
if (navigator.geolocation) {
browserSupportFlag = true;

navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
contentString = "您的当前位置";
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);

//----------------------自动保存坐标----------------------


//验证内容输入是否正确
latitude = position.coords.latitude;
longitude = position.coords.longitude;


var obj = '{ajax:"SubmitLocation",latitude:"' + latitude + '", longitude:"' + longitude + '"}';

$.ajax({
type: "POST",
url: "/MyAjax.aspx",
data: eval('(' + obj + ')'),
dataType: "json",
success: function(msg) {
if (msg.result == "0") {
alert("Error:" + msg.msg);
return false;
}
if (msg.result == "1") {

return false;
}
},
error: function(msg) {
alert("Error:" + msg + "请联系管理员");
}
});


}, function() {
handleNoGeolocation(browserSupportFlag);
});




} else if (google.gears) {
// Try Google Gears Geolocation
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.latitude, position.longitude);
contentString = "Location found using Google Gears";
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
} else {
// Browser doesn't support Geolocation
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
}


function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
initialLocation = newyork;
contentString = "错误:地理定位服务失败.";
} else {
initialLocation = siberia;
contentString = "错误:您的浏览器不支持地理位置.您在西伯利亚?";
}
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}

</script>

</head>
<body onload="initialize()">
<form id="Form1" runat="server">
<div class="Main">
<div class="Content">
<h1 class="Common">
GPS功能 <a href="GPS_Find.aspx" class="Btn_Com">寻找同事</a></h1>
<h2 class="Common">
<span>当前位置</span><p>
<a href="GPS.aspx" class="Btn_Com">刷新</a> <a href="#" id="Hand" class="Btn_Com">手动定位</a>
</p>
</h2>
<div class="List">
<%--<div id="Map" style="width:618px;height:548px">--%>
<div id="Map">
<div id="map_canvas" style="width: 308px; height: 100%">
</div>
<input type="hidden" id="hidLatitude" name="hidLatitude" runat="server" />
<input type="hidden" id="hidLongitude" name="hidLongitude" runat="server" />
</div>
</div>
</div>
</div>
</form>
</body>
</html>
加载中
0
梵高
梵高

似乎和手机的定制商有关系,因为谷歌地图不是免费的,比如我的安卓就一直用不了。

 

返回顶部
顶部