Support » Plugin: WP Geo » 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 code

    if (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)
  • Plugin Author Ben Huson


    Thank you, I like your suggestion.
    I’ll try to get an option for it added in a future version or hooks so it can be created as a separate plugin.

    I’ve been looking for soooo long for a plugin that can sort members by distance on a member search page…

    This plugin seems capable of creating a position database for each member…. it would be easy, after that, to sort members by distance…

    Is it possible for you to develop such a plugin ?

    Plugin Author Ben Huson


    This plugin does not currently allow you to save a location for users but I may try to add this functionality to a future version.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add user geolocation’ is closed to new replies.