Effekt (getestet in der neuen Version von Firefox):
Code:
<!DOCTYPE><br><html><br><head><br> <meta http-equiv="content-type" content="text/html;charset=utf-8"><br> <title>Google Map</title><br> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><br> <script type="text/javascript"><br> function init()<br> {<br> // 获取当前位置<br> navigator.geolocation.getCurrentPosition(function(position)<br> {<br> var coords = position.coords;<br> // 设定地图参数,将当前位置的经纬度设置为中心点<br> var latlng = new google.maps.LatLng(coords.latitude,coords.longitude);<br> var myOptions = <br> {<br> // 放大倍数<br> zoom:14, <br> // 标注坐标<br> center:latlng,<br> // 地图类型<br> mapTypeId:google.maps.MapTypeId.ROADMAP<br> };<br> var map1;<br> // 显示地图<br> map1 = new google.maps.Map(document.getElementById('map'),myOptions);<br> // 创建标记<br> var marker = new google.maps.Marker(<br> {<br> position:latlng,<br> map:map1<br> });<br> // 设定标注窗口,附上注释文字<br> var infowindow = new google.maps.InfoWindow(<br> {<br> content:"当前位置"<br> });<br> // 打开标注窗口<br> infowindow.open(map1,marker);<br> });<br> }<br> </script><br></head><br><body onload="init()"><br> <div id="map"></div><br></body><br></html>
Google Maps JavaScript API v3 (Referenzdokumentation): https://developers.google.com/maps/documentation/javascript/basics
Baidu Map API-Referenzdokument: http://developer.baidu.com/map/jsmobile.htm