Load map centered around a users location

Home Forums Feature Requests Load map centered around a users location

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #14103
    beaver
    Participant

    Hi Chris

    I want to load a mashup based on the current users location. I’m storing the users location in their meta data. What I want to do is get the users current location from the meta and then use that as the center point for the map and then display whatever locations are nearby. Probably setting a zoom level of 5. I want this to happen when the user clicks a link or button.

    Can you help me figure this out?

    Thanks

    #14110
    Chris
    Keymaster

    Hi, that kind of geolocation isn’t something the current plugin supports, so I think this is more of a feature request – I’ve moved it to that forum.

    I can explain how to center the map on a latitude/longitude using javascript, if that would help.

    #14117
    beaver
    Participant

    I can explain how to center the map on a latitude/longitude using javascript, if that would help.

    Hi Chris

    Yes, that would help. Please provide the details.

    Thanks

    #14123
    Chris
    Keymaster

    Hi,

    If you map is named ‘mapp0’ then this code will get the Google Map object for the map:

    var gmap = mapp0.getMap();

    With that object you can use any API functions. For example:

    gmap.setCenter(new google.maps.LatLng(0,0));

    The plugin will assign names to the maps as they are rendered (mapp0, mapp1…etc). You can also use the ‘name’ attribute of the shortcode to set your own name.

    I hope that helps!

    #14337
    beaver
    Participant

    Chris could you please elaborate on this code, like provide a complete example. I’m not sure if I’m supposed to create a function or add a query to the actual page.

    Thanks!

    #14338
    Chris
    Keymaster

    The code above is javascript to center a map. If you’re not already familiar with javascript programming in WordPress it won’t be much use.

    Code for searching near a user’s location is beyond what I can provide in the support forum – and it’s also the most frequent feature request. I’ve been working on it for a long time, but I have no ETA yet for when it will be available.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.