Import locations in Google maps plugin

Hi there,
I'd like to know whether there's a way to easily add 150+ locations to one Google map via your plugin. There does not seem to be an addon for that?

Cheers!
Ronald

  • jamie

    Hello Ronald,

    I am just a user here like yourself, but I have spent a lot of time using this plugin.

    That said, when you say "easily add" how easy are you talking?

    The question I would ask is where are these locations currently? is there any record of them already on the website or do you just have a list in a text file?

    Second question would be, how do you want to display this map? The reason I ask is because you can make this plugin automatically query all posts with the meta data of the location and it will create the maps will all the locations into one.

    At some point, though, you will have to put the locations in to the system. If you are looking for a method to upload a list with one click, I don't think you will find it (i've been wrong before). However, if you can find a plugin that can create posts from a list and have the location attached to each post as meta data that might be a way to get bulk data into your site, then use the [map query="data_field_name"] approach to gather all the posts/locations into a mashup map.

    Just my 2 cents,

    Jamie

    • Ronald

      Hi Ivan, thanks for responding, that's clear then...

      Hi Jamie, thanks as well for responding and asking indepth questions.
      I'd like to add a 100+ locations for a certain type of teachers, to show where they are located in the country (The Netherlands, in this case).

      Now, do I understand you right, that when each teacher has his own page with info about him- or herself, with location info mentioned in a certain format, I could automatically let this info be gathered in a mashup map?
      That sounds interesting and could be a solution. Any advice where I could learn more about that?

      Thanks again and have a nice sunday!

  • jamie

    Ronald,

    The pages that contain the address would have to either have to have the meta data that includes the address or use the [location] shortcode that contains a copy of the address within the page.

    The way I assign the meta data is through a form that automatically creates the meta data when user enters data into the form (database). You can see and add meta data ( aka custom fields) by while on the page edit screen:

    Make sure at the top of the page you have "screen options" set to show custom fields. Then under your content you will see something that looks like this:

    http://jamiekeefer.com/custom_fields.png

    That image includes the "associated map" and the "location" custom fields and some other fields I use to manage posts.

    Now, in your case I am assuming the teachers address information is simply entered into the page as text, so the trick will be to get that information to either make a map with the address and associate it with the post, or get the address into the meta data like the location field I have.

    As I mentioned, I create the location field from user input and then use the "custom fields" feature of the google maps plugin to create the map automatically. The plugin automatic process created the "agm_map_created" field and assigns the value. The simpliest mashup will look at all posts with that field and include them. You can filter which maps show up a few ways, and examples are here: https://premium.wpmudev.org/project/wordpress-google-maps-plugin/#usage (look for header "The following shortcodes can be used in posts to create mashups:")

    Now with all that said, if I am correct in assuming the address is entered as text, the easies way to get that info into the maps is to use the [location] shortcode on each page. The location shortcode allows for inline placement of maps, but it also will associate a map to the post like above example. You may want to testthis to see if it is still doing that by entering a location shortcode on a page - it will result in map on the page, and then check to see if the custom field exists for the mashup.

    [location] shortcode is an add-on you can activate within the many features of the google maps add-on section.

    The question remains, however, how to get all those location shortcodes in place? Before I started this long-winded post, I imagined you could open perhaps ten pages at a time and using copy and paste just paste the location shortcode around the existing address. This would at least avoid having to retype each address. Not an ideal solution, but at least less laborious.

    After consideration, perhaps even easier you can copy the address on each page and using the "add custom field" shown in the above image, copy and paste from the text body into there.

    I have gone on long enough, LOL. Let me know if that makes any sense.

    Sincere regards,

    Jamie

  • Ronald

    Hi Jamie,

    Thx for the efforts you took to answer me.
    It surely makes sense, and I think might be a (the?) solution to my question.
    I have to read it a few times and experiment a bit, but will surely let you know how things went!
    @WPMU dev team: this could be a nice subject for a tutorial, for which Jamie delivered a substantial part...

    Thanks again, Jamie, and I'll be back, to paraphrase Arnold S., to let you know or with further questions.

    Cheers!

  • jamie

    It should work with custom post types. Granted it may require some creativity with the use of the shortcodes and perhaps tags associated with the posts.

    I use pages to display the maps, but reference posts taxonomies and meta data. Pages can have meta data associated, but I was not able to get the google maps plugin to reference the pages for the mashups using the same meta data I use for the posts. For example, the [map query="current"] will look at all posts that are on my site and look for the meta data agm_map_created and add the corresponding map to the plugin. I went so far as to manually add the meta fields in a test page and the [map query="current"] did not show it in the mashup.

    It seems the plugin is only looking at posts for the mashups out of the box. One thing that might work if you absolutely need pages, is to add tags to pages (pages usually don't have that funtionality despite being glorified posts) using something like this: http://www.sitepoint.com/wordpress-pages-use-tags/

    Once you have tags on the pages you might be able to reference them in a mashup using [map query="tag=tagname"], but I have not tested that.

    You'll have to weigh the options on how to organize stuff, and I am sure where there is a will there is a way. One thing that comes to mind is for each instructor page, there is a correlating post in the background used just to generate the maps. The databases I maintain I tend to always make a post of the record to provide functionality since everything about wordpress revolves around posts. I may be unorthodox in this approach, but it seems like a good idea for my use and also looking forward to the WP JSON API that allows access to post data.

    To give you an idea how I used it, the site url is http://www.readytoplaynow.com. Click on "all events" to see maps (icons lead to maps specific to catagories), and keep in mind this is mostly North America, so you may have to zoom out to see the map markers. Also, there is just test data in there now, as we prepare the next part of the site construction prior to launch.