復(fù)制代碼代碼如下: script type="text/javascript" var map; var browserSupport = false; var attempts = 0; $(document).ready(function () { //初始化地圖 InitMap(); //定位 getLocation(); //定位跟蹤 watchLocation(); }); function InitMap() { /* Set all of the options for the map */ var options = { }; /* Create a new Map for the application */ map = new google.maps.Map($('#map')[0], options); } /* * If the W3C Geolocation object is available then get the current * location, otherwise report the problem */ function getLocation() { } function watchLocation() { } /* Plot the location on the map and zoom to it */ function plotLocation(position) { } /* Report any errors using this function */ function reportProblem(e) { } /script
復(fù)制代碼代碼如下: function plotLocation(position) { attempts = 0; var point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var marker = new google.maps.Marker({ position: point }); marker.setMap(map); map.setCenter(point); map.setZoom(15); }