Plot multiple locations on Google Maps

Plot multiple locations on Google Maps

Hey all

A few days ago, I had two appointments downtown in the financial district on the same day. I wasn’t sure how close they were to each other, so I got the idea to look them up on google maps. However, I soon found out that you cannot plot more than one location on google maps at a time. (Well, that’s not completely true, since you could plot one point, and then get directions from there to the other place. But then what would you do if you needed to plot three places?)

So, I decided to see if I could hack something together using the Google Maps API. The result is at:
http://gmaps.kaeding.name

It isn’t pretty, nor is it perfect, but hey, it works (at least when the addresses are accepted by the geocoder).

You enter as many addresses as you want, one per line. Then the script sends those strings through geocoder.us to get latitude and longitude. (The Google Maps API only allows you to plot points using latitude and longitude, not by supplying an address). Sometimes, geocoder.us will come back with more than one possible address for a single string. So, the next page asks you to confirm the addresses. The final page displays the map.

[ad]

The flaws right now are that the map will always be centered on the first point, and the zoom level is set at 5. Of course, you can move it around, but it would be nice if the program automatically zoomed/centered the map to show all of your points.

Also, sometimes the geocoder doesn’t like certain addresses. For example, numbered roads don’t work (like state highways). All areas of Boston list Boston as the city (for example, addresses in Jamaica Plain, which is part of Boston, will come back as Boston). These problems are caused by incomplete data in the TIGER data set, which was generated by the Census.

Also, the page that asks you to confirm the addresses doesn’t show you were the suggestions are (it displays the address, with zip code, but not a map or anything. That would be cool.)

Anyway, give it a shot, and let me know what you think.

-Patrick

PS-
Here’s the link again:
http://gmaps.kaeding.name

UPDATE: I just changed the links above to point to the new location. If you had already bookmarked the old spot, please update.

This entry was posted in gmaps.kaeding.name and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

19 Comments

  1. B M
    Posted March 17, 2009 at 5:20 pm | Permalink

    Could you fix it so that the number on the list is on the bubble so that if you print the list out and the map, the numbers correspond to the locations?

  2. Jon
    Posted October 9, 2009 at 8:47 pm | Permalink

    Patrick,

    I have a couple of questions about this. How can I contact you? Thanks.

  3. Kevin
    Posted January 25, 2010 at 5:21 pm | Permalink

    This isa great idea!

  4. Posted March 19, 2009 at 1:36 pm | Permalink

    That is a good idea. I will look into adding this feature when I get some free time.

  5. Posted February 23, 2010 at 7:47 pm | Permalink

    Hi Patrick, — This is a great start, but there may have been a flaw introduced, in that I entered 3 map positions, all with the same Latitude but the resulting map indicated points at different Latitudes. Just in case it is data dependent, here is what I entered:
    45.6404,-93.9771{Easterly point}
    45.6404,-93.9775{w}
    45.6404,-93.9789
    Maybe it is the format? I appreciate your effort, and esp. the query save feature.
    By the way, what & where is the volcanic rock over here on the right?
    — Greg M. in Minnesota

  6. Posted February 23, 2010 at 10:04 pm | Permalink

    Hi Greg

    What is happening here is a result of how I am handling the input ‘addresses’. I am passing the location (minus the description in curly-braces) to the Google geocoding service, which is designed to translate between street addresses and latitude/longitude coordinates. A side effect of this is that if you input coordinates, Google assumes that you want to find the closest street address to those coordinates. Thus, you have the locations you plotted following Rte 23. You can see the address it is using by clicking on the markers on the map. You will see something like “8901-9499 Minnesota 23 Trunk, Foley, MN 56329, USA”

    So, in order to allow users to plot coordinates (and not force these locations into street addresses), I would need to run a check to see if the ‘address’ appears to be coordinates, before sending the it off to Google for geocoding. This is certainly doable, and I will add it to my list of enhancements that I will add when/if I have the time, but I think it would probably benefit very few users (as most people are entering street addresses in the first place).

    I hope that answers your question.

    The volcanic rock photo on the right (and in the title bar) are from my trip to Hawaii Volcanoes National Park this past January. It was a lot of fun; we saw some amazing landscapes!

  7. Ana Arellano
    Posted February 24, 2010 at 8:22 am | Permalink

    Hi Patrick ,
    I thought I had posted my comment yesterday, but could not find it this morning. I apologize if I repeat myself.
    First I am a complete amateur, and I am plotting (?) for my non-profit. I would like to plot the addresses of all of our 200+ donors so as to have events by neighborhood, visits by neighborhood, etc.
    Is that number too big?
    Also, I know that I can save my map by creating a new URL. Is there any way I can go back and edit a URL ( same exact address)? Or, can I delete an address and re-use it?
    Thank you for creating such wonderful and useful powers for Google Maps!
    Sincerely,
    Ana

  8. Posted February 24, 2010 at 11:50 pm | Permalink

    Hi Anna

    Yes, your first comment did go through. It was just added to my moderation queue, since you were a first-time commenter. (Now that I have marked you as not a spammer, your comments should be automatically approved.)

    You are right about not being able to edit saved maps. This was a decision I made early on, since I didn’t want to force users to sign up for the service, and create a password (which they might forget, and then I would need to create a way for them to recover the password, etc). So, once you create a map, it is final. You are certainly welcome to create a new map, but your old one will remain. If you have frequently changing data, I suggest creating a naming scheme, like ‘AnasNonProfitFeb2010′. Next month, you can create the new version, ‘AnasNonProfitMarch2010′.

    Thanks!

  9. John
    Posted June 24, 2010 at 5:08 am | Permalink

    Doesn’t look like you’ve touched this in years. It would have been much more useful it if had labels. I plotted 15 locations, so it’s nice to see it on a map, but I don’t know which one belongs to what. But, thanks it should provide some help.

  10. John
    Posted June 24, 2010 at 5:08 am | Permalink

    Nevermind. I just wrote them on the printed paper by hand. Close enough.

  11. Posted June 24, 2010 at 7:07 am | Permalink

    Hi John

    Yeah, it has been a while since I’ve had time to work on it. You aren’t the only one who has requested this though, so I do plan on adding this feature when I get a chance.

    Thanks!

  12. Posted July 26, 2011 at 6:43 pm | Permalink

    I’ve been looking around trying to find a tool to do this. I’ve just made a map with 700 sales leads. I can’t imagine how much time (and gas) you’re gonna save me. Sincere thanks, you’ve made my day!

  13. shawn
    Posted November 3, 2011 at 12:18 pm | Permalink

    being able to plot multiple lat/long coords would be useful to me as well.

  14. Chris Bradley
    Posted February 26, 2012 at 6:35 am | Permalink

    I love this mapping feature. Is there a way to erase the info later once you have posted it?

  15. Posted February 29, 2012 at 8:07 am | Permalink

    Hi Chris

    Yes, I replied to your email and removed your maps.

    Thanks!

  16. Posted April 15, 2012 at 9:21 pm | Permalink

    Thanks, I was having to search cities individually for a project and that was slow and tedious. Super helpful!

  17. Daniel
    Posted May 15, 2012 at 8:17 am | Permalink

    Was wondering what version of Google API are you using(free, business, enterprise?) because I can’t seem to be able to plot multiple points using the free api.

  18. Posted May 17, 2012 at 9:14 pm | Permalink

    Hi Daniel

    Take a look at the Google Maps API docs, you should be able to just create multiple Marker objects.

  19. Ruth
    Posted November 22, 2013 at 3:09 pm | Permalink

    This is a great site! Helpful for a project I’m working on!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>