Support » Plugin: Simple Location » How do I access the lat/long of a post?

  • I appreciate that Simple Location has let me enter the lat/long of a post in the Edit Post UI, something the last-updated-11-years-ago plugin GeoPress no longer does.

    But I don’t see anything in Simple Location that lets me get that information out, which I’d like to do in the javascript code for the header for each post. (From that I can manufacture a URL to open a map in a separate page.)

    What am I missing?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Shanske

    (@dshanske)

    For locations shared publicly, this is added to the post endpoint of the REST API. You can get it from there.

    There’s also a variety of endpoints built into the plugin. They usually require authentication because of API limits on various APIs used to get map data.

    Most of the display code is in PHP, but I added endpoints. I should document better.

    Could you elaborate on what exactly you want and I can try to help? If exactly what you are looking for isn’t available I might be able to modify.

    I create a post. In the Edit Post UI, your plugin lets me enter lat/long. So did my previous plugin.

    In “functions.php”, I’m generating a string, to be displayed at the top of each post, showing where it was posted from. I consider all posts and their locations public; I don’t know whether or not your code does, or how I would tell it.

    In my previous plugin, there was a function post_google_url() I could call to get a URL to Google Maps for the post’s location. Those URLs are easy enough to construct, assuming I have lat and long as strings.

    I’m not familiar with how to use the REST API in WordPress plugins — most of my programming work is non-web. If there were getPostLat() and getPostLong() functions, or if you could provide a sample of how to write one, it would be tremendously helpful. (Also, I will google “REST API in WordPress plugins” and see if that provides any clues.)

    Thanks for getting back to me!

    Plugin Author David Shanske

    (@dshanske)

    WP_Geo_Data::get_geodata() will return an array with latitude, longitude, and visibility (whether to display it or not)

    Loc_View::get_map() will return a map in html for display

    Loc_View::get_location will return the location marked up for display.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I access the lat/long of a post?’ is closed to new replies.