国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Google Maps API地圖應用示例分享

2019-11-20 14:00:00
字體:
來源:轉載
供稿:網友

效果(新版Firefox中測試):

代碼:

<!DOCTYPE>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Google Map</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function init()
{
// 獲取當前位置
navigator.geolocation.getCurrentPosition(function(position)
{
var coords = position.coords;
// 設定地圖參數,將當前位置的經緯度設置為中心點
var latlng = new google.maps.LatLng(coords.latitude,coords.longitude);
var myOptions =
{
// 放大倍數
zoom:14,
// 標注坐標
center:latlng,
// 地圖類型
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map1;
// 顯示地圖
map1 = new google.maps.Map(document.getElementById('map'),myOptions);
// 創建標記
var marker = new google.maps.Marker(
{
position:latlng,
map:map1
});
// 設定標注窗口,附上注釋文字
var infowindow = new google.maps.InfoWindow(
{
content:"當前位置"
});
// 打開標注窗口
infowindow.open(map1,marker);
});
}
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

Google Maps JavaScript API v3(參考文檔):https://developers.google.com/maps/documentation/javascript/basics

百度地圖API的參考文檔:http://developer.baidu.com/map/jsmobile.htm

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 望谟县| 兴业县| 军事| 军事| 望都县| 林芝县| 徐闻县| 盐边县| 鹰潭市| 青海省| 中江县| 托克逊县| 响水县| 河曲县| 甘南县| 揭西县| 峡江县| 霍山县| 仪征市| 陇南市| 米易县| 怀仁县| 恭城| 鹿邑县| 新闻| 湖口县| 昆明市| 绥滨县| 河西区| 宝坻区| 克拉玛依市| 繁峙县| 张家口市| 阿勒泰市| 乌拉特前旗| 古交市| 邹平县| 海原县| 察雅县| 瓮安县| 穆棱市|