国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊川县| 喜德县| 巩义市| 美姑县| 寿光市| 双辽市| 札达县| 东宁县| 井冈山市| 永年县| 左贡县| 六盘水市| 娄烦县| 深州市| 梓潼县| 茶陵县| 临夏市| 台南市| 乐业县| 瓦房店市| 南投县| 莱阳市| 铜川市| 神木县| 海阳市| 日照市| 中山市| 遂宁市| 会昌县| 巴青县| 潼关县| 沙洋县| 景德镇市| 南皮县| 文水县| 石台县| 高要市| 井研县| 商水县| 江油市| 许昌市|