Add location to post and custom post then show on the map

Hi,

Can we use this plugin to add geo location info (not my location) to the post and custom post type, and display them on the map?

When we click the marker then we can view the post/custom post.

Thanks,

  • wmv
    • Design Lord, Child of Thor

    HI PC,

    Thanks for the quick response. But when I use [map query="all"] to a page.

    It will show two maps, one with the map I created and the other one will have show a marker with the Custom Post. (so that is two maps on one page)

    Ideally, we want to have one map to show all the posts/custom posts with location info added in the custom fields, and then when click the marker on the map user will be directed to that post/custom post.

    With the shortcode [map query="all"], it will only show marker on the map with direction (for how to get there) but not link to the post.

    Any idea what we should do?

    Thanks again,

  • Jose
    • Bruno Diaz

    Hey there @wmv,

    Hope you are good today and sorry for the delay.

    I was struggling around this issue for a while.

    The solution is a combination of plugin setup and a small bug fix.

    First, you need to go under Settings->Google Maps and configure the Custom fields options as showed in the first attached image. I run my test using the Address field name, but it works the same with Latitude and Longitude. For the field name you can choose the name that you like, in this case I use "map_address".

    Second, you will need to create a new custom field for you posts matching the same field name, in this case "map_address". See second image.

    Then, you can use the following shortcode to achieve what you want:
    [map query="all" show_posts="true" overlay="true"]

    The expected behavior is the one showed in the 3rd image. One marker for each post, and a link targeting the associated post inside the info context window.

    Next, you need to check if the links are rendering as expected. In my tests, sometimes the links are not showed, and it is because there is a little bug. The links rendering is out of sync. If this is the case for you, then you need to hack one line of code inside the plugin.
    Edit the file {plugin_folder}/js/google_maps_user.js and change the line 522 from this:
    populateLinksToPostsMarkup();
    to this:
    setInterval(function(){populateLinksToPostsMarkup();},1000);

    Please let me know if this whole thing works for you. I'll be here to assist you and sort it out.

    Cheers!
    JJ

  • Dutchman
    • The Bug Hunter

    This is awesome. I landed on this topic, because I was looking for the same thing: Having a map to show my posts as pins.

    I hope you don't mind me following up on this with my question:

    Is it also possible to have different colors of pins on the map depending on post category?

  • Rupok
    • Support Ninja

    Hi Dutchman

    Hope you had a wonderful day.

    I'm afraid, having different colors of pins on the map depending on post category won't be possible with currently available options but I'm pinging Jose if he can provide any valuable feedback on this.

    Have a nice day. Cheers!
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.