Skip to content

Google Maps plugin that allows to add a geolocation control.

License

Notifications You must be signed in to change notification settings

Raruto/google-geolocate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-geolocate.js

A Google Maps plugin that allows to add a geolocation control.

For a working example (without API Key) see demo


Google+Geolocate Control

How to use

  1. include CSS & JavaScript
    <head>
    ...
    <style>html, body, #map { width: 100%; height: 100%; margin: 0; padding: 0; }</style>
    <script src="https://maps.google.com/maps/api/js?key=<INSERT_HERE_API_KEY>"></script>
    <script src="https://raruto.github.io/cdn/google-geolocate/0.0.1/google-geolocate.js"></script>
    ...
    </head>
  2. choose the div container used for the slippy map
    <body>
    ...
    <div id="map"></div>
    ...
    </body>
  3. create your first simple “google-geolocate” slippy map
    <script>
      var mapOpts = {
        center: new google.maps.LatLng(45, 9.5),
        zoom: 5,
        MapTypeId: google.maps.MapTypeId.ROADMAP
      };
    
      var map = new google.maps.Map(document.getElementById('map'), mapOpts);
      var geolocationControl = new GeolocationControl(map, 13);
    </script>

NB to be able to use the “Geolocator API” (a.k.a. “MyLocation Button”) you MUST own:


Compatibile with: [email protected]


Contributors: Raruto