Add user geolocation
-
I love this smart plugin.
I would like to share a small hack to display the user position in the widget map (contextual or category map). I edited wpgeo-widget.php, inside the folder ‘/widgets’, and I add this codeif (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var latitude = parseFloat( position.coords.latitude ); var longitude = parseFloat( position.coords.longitude ); marker'. count( $coords ) .' = wpgeo_createMarker(new GLatLng(latitude,longitude), ' . $icon . ', "You", "#"); //recalculates center and zoom level of the map var center = bounds.getCenter(); var zoom = map.getBoundsZoomLevel(bounds) if (zoom > ' . $args['zoom'] . ') { zoom = ' . $args['zoom'] . ';} map.setCenter(center, zoom); }); }
in js function createMapWidget(), under
'.$markers_js .'
I hope it can be a useful starting point!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add user geolocation’ is closed to new replies.