• Resolved hcyja1

    (@hcyja1)


    Hi! Would it be possible to zoom on a marker pin through the browser’s url?

    For example,zooming to a particular marker pin through the link
    https://www.examplesite.com/map/?pinId=xx

    This is because I have a page which shows only the map in full size, and also at the bottom of each blog post I have a call to action button which brings users to the mentioned page with the map in full size. Though i’m also trying to develop it such that when users click on the link, they’ll be brought to the map page and zoomed in at the particular post they came from.

    Sort of like the [centered_on_this=true], but through url. Thank you very much for the plugin and your hard work in developing it by the way!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Camille V

    (@socrapop)

    Dear @hcyja1,

    It is not possible as is with the plugin, no.

    Markers are not javascript objects yet, so it is impossible to access their data after page loading. I’m working with Camille to enhance code quality of the plugin and give this kind of possibility for other developers.

    For now, I can think of two solutions:

    • You could get the latitude and longitude of the post with this wordpress function get_post_meta($postid, '_latlngmarker');
      All you have to get is the $postid you want, and then you can convert this JSON array and get the latitude and longitude.
    • You can also use a site.com/map/?lat=90.00&long=70.00 url, so that you use those parameters to zoom where you want.

    After that, you can use Leaflet functions to zoom and pan where you want.
    I wrote a developer documentation to interact with the maps:
    https://camilles-travels.com/get-started-with-travelers-map-wordpress-plugin/#dev-documentation
    The first code snippet is exactly what you want to use, the leaflet setView() method.

    Have a nice day,
    Camille

    Thread Starter hcyja1

    (@hcyja1)

    Thank you very much for your help, appreciate it a lot. Will try out your solution!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Centered on post marker through href’ is closed to new replies.