<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="jquery-1.8.0.js"></script>
    <script type="text/javascript">
        function runMap(lat, lng) {
            var latlng = new google.maps.LatLng(lat, lng);
            var myOptions = {
                zoom: 15,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
        }
        $(function () {
            var lat,
lng;
            //try to get GPS coords
            if (navigator.geolocation) {
                //redirect function for successful location
                function gpsSuccess(pos) {
                    if (pos.coords) {
                        lat = pos.coords.latitude;
                        lng = pos.coords.longitude;
                        runMap(lat, lng);
                    }
                    else {
                        lat = pos.latitude;
                        lng = pos.longitude; runMap(lat, lng);
                    }
                }
                function gpsFail() {
                    //Geo-location is supported, but we failed to get your coordinates. Workaround here perhaps?
                }
                navigator.geolocation.getCurrentPosition(gpsSuccess, gpsFail, { enableHighAccuracy: true, maximumAge: 300000 });
            }
        })
    </script>
</head>
<body>
    <div ></div>
    <script type="text/javascript">
       
    </script>
</body>
</html>

相关文章:

  • 2021-07-27
  • 2022-02-23
  • 2022-12-23
  • 2021-09-22
  • 2021-12-21
  • 2021-12-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2021-12-19
  • 2022-01-01
  • 2021-12-19
  • 2022-12-23
相关资源
相似解决方案