Title: Geolocation
Last modified: August 31, 2016

---

# Geolocation

 *  [remy.hallot](https://wordpress.org/support/users/remyhallot/)
 * (@remyhallot)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/geolocation-9/)
 * Hi,
 * I really like your plugins and think about buying the premium version.
 * But before i have 2 questions. First, is it possible to add geolocation to the
   plugins ? The best will be after the map the users is prompted to accept geolocation.
   If yes, the map center on the user location.
 * Second questions, Is it possible to load the marker on a side windows when you
   scroll on the maps ( something like airbnb does with their map) ?
 * Regards,
 * [https://wordpress.org/plugins/hero-maps-pro/](https://wordpress.org/plugins/hero-maps-pro/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [JaydonV](https://wordpress.org/support/users/jaydonv/)
 * (@jaydonv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/geolocation-9/#post-7013485)
 * Hi Remy
 * Unfortunately the geolocation function in Maps Premium only works for getting
   directions – ie. when the user clicks on a Get Directions button in an infobox(
   assuming it is switched on in your settings), it will determine his location 
   and provide directions to that marker.
 * With regards to your second question – unfortunately this functionality isn’t
   possible in Hero Maps.
 * Kind regards
    Jaydon
 *  Thread Starter [remy.hallot](https://wordpress.org/support/users/remyhallot/)
 * (@remyhallot)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/geolocation-9/#post-7013580)
 * Hi,
 * I managed to add a button to geolocate users to your maps by adding this code
   to frontend_script.js
 * This goes at the end of function hmapsprem_inject_map
 *     ```
       var geolocateControlDiv = document.createElement('div');
       var geolocateControl = new GeolocateControl(geolocateControlDiv, google_map);
   
       geolocateControlDiv.index = 1;
       google_map.controls[google.maps.ControlPosition.TOP_CENTER].push(geolocateControlDiv);
       ```
   
 * And add also this function
 *     ```
       function GeolocateControl(controlDiv, map) {
   
       	// Set CSS for the control border.
       	var controlUI = document.createElement('div');
       	controlUI.style.backgroundColor = '#fff';
       	controlUI.style.border = '2px solid #fff';
       	controlUI.style.borderRadius = '3px';
       	controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
       	controlUI.style.cursor = 'pointer';
       	controlUI.style.marginBottom = '22px';
       	controlUI.style.Top = '10px';
       	controlUI.style.textAlign = 'center';
       	controlUI.title = 'Click to recenter the map';
       	controlDiv.appendChild(controlUI);
   
       	// Set CSS for the control interior.
       	var controlText = document.createElement('div');
       	controlText.style.color = 'rgb(25,25,25)';
       	controlText.style.fontFamily = 'Roboto,Arial,sans-serif';
       	controlText.style.fontSize = '16px';
       	controlText.style.lineHeight = '38px';
       	controlText.style.paddingLeft = '5px';
       	controlText.style.paddingRight = '5px';
       	controlText.innerHTML = 'Geolocation';
       	controlUI.appendChild(controlText);
   
       	// Setup the click event listeners
       	controlUI.addEventListener('click', function() {
       		navigator.geolocation.getCurrentPosition(function(position) {
       			var pos = {
       				lat: position.coords.latitude,
       				lng: position.coords.longitude
       			};
   
       			map.setCenter(pos);
       			map.setZoom(17);
       		}, function() {
       			handleLocationError(true, infoWindow, map.getCenter());
       		});
       	});
       }
       ```
   
 *  [JaydonV](https://wordpress.org/support/users/jaydonv/)
 * (@jaydonv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/geolocation-9/#post-7013632)
 * Hi Remy
 * Thanks for sending this to us. I’m forwarding this to our Maps dev – I’ll put
   in a suggestion to have this implemented in a future build of Maps as well.
 * Could I ask you to send us a support ticket at [http://heroplugins.com/support](http://heroplugins.com/support)
   as well – I have one or two questions I would like to address with regards to
   this as well.
 * Kind regards
    Jaydon

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Geolocation’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/hero-maps-pro_aa9997.svg)
 * [Hero Maps Pro](https://wordpress.org/plugins/hero-maps-pro/)
 * [Support Threads](https://wordpress.org/support/plugin/hero-maps-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/hero-maps-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hero-maps-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hero-maps-pro/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [JaydonV](https://wordpress.org/support/users/jaydonv/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/geolocation-9/#post-7013632)
 * Status: not resolved