google-geolocate.js
A Google Maps plugin that allows to add a geolocation control.
For a working example (without API Key) see demo
How to use
- 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>
- choose the div container used for the slippy map
<body> ... <div id="map"></div> ... </body>
- 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:
- a valid SSL Website.
- a valid Google Maps API Key
Compatibile with: gmaps@3.34
Contributors: Raruto