Title: Global Map, position via GeoLocation (JavaScript(
Last modified: December 2, 2019

---

# Global Map, position via GeoLocation (JavaScript(

 *  Resolved [letsfetz](https://wordpress.org/support/users/letsfetz/)
 * (@letsfetz)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/global-map-position-via-geolocation-javascript/)
 * Hi Guys,
 * I want to have GeoLocation in my Global Map. Therefor I went through all the 
   javascript and PHP files to figuere out where the Google Maps coding including
   API is done. If I’m not wrong the global Map is coded in the Events_manager.js
   file.
 * There fore I added the following code in the function em_maps_load_loacation(
   el), but it doesn’t work. In my understanding with this code it would just create
   a info.Window at the position of the customer.
 * I’m really a beginner in coding so it’s difficult to find the failure…
 * Hope someone can help! Thanks.
 *     ```
       function em_maps_load_location(el){
   
       	el = jQuery(el);
   
       	var map_id = el.attr('id').replace('em-location-map-','');
   
       	em_LatLng = new google.maps.LatLng( jQuery('#em-location-map-coords-'+map_id+' .lat').text(), jQuery('#em-location-map-coords-'+map_id+' .lng').text());
   
       	//extend map and markers via event triggers
   
       	var map_options = {
   
       	    zoom: 14,
   
       	    center: em_LatLng,
   
       	    mapTypeId: google.maps.MapTypeId.ROADMAP,
   
       	    mapTypeControl: false,
   
       	    gestureHandling: 'cooperative'
   
       	};
   
       	if( typeof EM.google_map_id_styles == 'object' && typeof EM.google_map_id_styles[map_id] !== 'undefined' ){ console.log(EM.google_map_id_styles[map_id]); map_options.styles = EM.google_map_id_styles[map_id]; }
   
       	else if( typeof EM.google_maps_styles !== 'undefined' ){ map_options.styles = EM.google_maps_styles; }
   
       	jQuery(document).triggerHandler('em_maps_location_map_options', map_options);
   
       	maps[map_id] = new google.maps.Map( document.getElementById('em-location-map-'+map_id), map_options);
   
       	var marker_options = {
   
       	    position: em_LatLng,
   
       	    map: maps[map_id]
   
       	};
   
       	jQuery(document).triggerHandler('em_maps_location_marker_options', marker_options);
   
       	maps_markers[map_id] = new google.maps.Marker(marker_options);
   
       	infoWindow = new google.maps.InfoWindow({ content: jQuery('#em-location-map-info-'+map_id+' .em-map-balloon').get(0) });
   
       	infoWindow.open(maps[map_id],maps_markers[map_id]);
   
       	maps[map_id].panBy(40,-70);
   
               if (navigator.geolocation) {
                                   navigator.geolocation.getCurrentPosition(function(position) {
                                       var pos = {
                                       lat: position.coords.latitude,
                                       lng: position.coords.longitude
                                       };
   
                                       infoWindow.setPosition(pos);
                                       infoWindow.setContent('Location found.');
                                       infoWindow.open(maps[map_id]);
                                       map.setCenter(pos);
                                   }, function() {
                                       handleLocationError(true, infoWindow, maps[map_id].getCenter());
                                   });
                           } else {
                                   // Browser doesn't support Geolocation
                                   handleLocationError(false, infoWindow, maps[map_id].getCenter());
                                   }
   
   
                               function handleLocationError(browserHasGeolocation, infoWindow, pos) {
                                   infoWindow.setPosition(pos);
                                   infoWindow.setContent(browserHasGeolocation ?
                                                       'Error: The Geolocation service failed.' :
                                                       'Error: Your browser doesn\'t support geolocation.');
                                   infoWindow.open(maps[map_id]);
                               }
       ```
   
    -  This topic was modified 6 years, 6 months ago by [letsfetz](https://wordpress.org/support/users/letsfetz/).
    -  This topic was modified 6 years, 6 months ago by [letsfetz](https://wordpress.org/support/users/letsfetz/).
    -  This topic was modified 6 years, 6 months ago by [letsfetz](https://wordpress.org/support/users/letsfetz/).

Viewing 1 replies (of 1 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/global-map-position-via-geolocation-javascript/#post-12207228)
 * Sorry, I’m afraid that we are quite limited with regards to custom coding as 
   per the support policy
 * [http://eventsmanagerpro.com/support-policy/](http://eventsmanagerpro.com/support-policy/)

Viewing 1 replies (of 1 total)

The topic ‘Global Map, position via GeoLocation (JavaScript(’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/global-map-position-via-geolocation-javascript/#post-12207228)
 * Status: resolved