WordPress.org

Ready to get started?Download WordPress

Forums

WP Geo
Add user geolocation (4 posts)

  1. Stefano Colarelli
    Member
    Posted 1 year ago #

    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!

    http://wordpress.org/extend/plugins/wp-geo/

  2. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. martinbeaulne
    Member
    Posted 1 year ago #

    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 ?

  4. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.