Custom Google Maps

Recently, I launched our new Interactive Campus Map that integrates with the Google Maps interface. Some of you may remember my past experiences working with the Google Maps API. Well, this is much more complicated. Although this took me more time than I would have liked to get working, I now know my way around the API (mostly). This is a huge advantage moving forward because there’s even more that I can do with it and even more to come.

Unlike the last post, this will not be a tutorial but more of a guide to get you started. You may want to walk through my source code to understand what I’m talking about. If you haven’t yet read my previous post on how to get a simple Google Maps working on your site, you might want to start there. Okay, let’s get to it.

Here’s a list of tools and resources that I used:

What I wanted out of my custom Google Map was to use my own images (Google calls these tiles), to be able to zoom in and out, have a marker for every building with some data in the info bubble, and have some kind of search function. What you end up with is a fully interactive map in an interface that most users will already be familiar with.

Here are the steps you need to take to integrate a custom tiled map onto your site:

  1. Find an image to use, preferably one with high quality for zooming
  2. Use this tool to figure out the coordinates of your tiles over the standard Google Maps tiles. NOTE: if you plan on showing the standard Google Maps in addition to your custom map, you will need to ensure your image lines up and scales correctly. If you do not do this, the markers you place later will be aligned incorrectly. However, if you know you only want to show your custom map, you can be a little more forgiving on the coordinates.
  3. Once you obtain the coordinates, you can configure the Automatic Tile Cutter script.
  4. After you plug in your options and save the file, go into Photoshop, open your image and run the script (File->Scripts->Browse). Here it will cut up your image into 256×256 squares for all of the different zoom levels you wanted.
  5. Now that you have all of your images, you are ready to add the code to make them show up in Google Maps. Follow the steps in the Mapki to create all of the GCopyright Javascript objects you need.
  6. The next step is to add the custom GTileLayer object. This is what tripped me up the most because the Mapki’s tile function is a little out of date. I referenced this tutorial and used the second CustomGetTileUrl function at the bottom of the page. Eventually, I added bounds checks to display a blank image outside of the x/y coordinates. NOTE: the zoom levels passed to the GTileLayer are based off an array numbering system. For example, my lowest zoom level is 15 and my highest is 17. Therefore, in the GTileLayer object I must pass 14 and 16, respectively, in order for the tiles to show up correctly.
  7. Now all that is left to do is add our custom map and center it.
  8. From there, you can add your own markers via XML. Make your life easier by storing your data in a CSV file and generating the XML from that. If you were industrious, you could store your data in a SQL database and dynamically generate the XML that way.

Whew. As you can see, there’s really a lot to it with quite a few pitfalls. Google doesn’t make this any easier by providing less than helpful documentation. Plus, whatever tutorials you find are either too simple or out of date. But, the upside is that Google lets you customize just about any aspect that you would like. The one downside I would point out is that we can’t have a “Directions To/From Here” function yet. Because of all the construction and road changes around campus, the default Google Maps tiles have yet to be updated which means Google’s directions would be incorrect most of the time.

Keep an eye on the Interactive Campus Map because it will continue to be improved with new functionality. If you have any questions, just let me know.

UPDATE

The campus map has been updated and no longer uses custom tiles.  For more information on this change, please read this post.  However, if you would still like to see the results of the above steps, click here to view the old custom Google map.

About these ads

22 thoughts on “Custom Google Maps

  1. Awesome – excellent work!

    We tried doing something very similar to this for checking open lab locations. In the end it got shuffled around for higher priorities – so I’m glad you are able to move into some of this newer, interactive scripting work. Kudos!

  2. Great work, Matthew. That’s one of the most awesome AND useful things I’ve seen in a while. I love how it illustrates that we can use mashups in an institutional setting; we don’t have to create everything from scratch.

  3. Pingback: Additional Functionality with Custom Google Maps « WebTide

  4. Excellent article Matthew. If also been struggling with the principles behind making my own custom map and Google’s scanty examples.

  5. Hi Matthew-

    Good point about our scant resources about custom maps. Would you be amenable to me linking to this article from our documentation? (Feel free to contact me personally to let me know). Thanks!

  6. Pingback: 2 New Articles: PHP/MySQL for the Flash API, and Custom Icon Creation with the JS API | Padub

  7. Pingback: Interactive Campus Map v2.0 « WebTide

  8. Hi,

    I wanted to know if the tool to calculate the coordinates in step 2 worked fine for you. In my case, the coordinates are wrong always. Could you help me, please?

    Regards,

  9. Pingback: How to create your own Google Map | Kollermedia.at

  10. Pingback: Tutorial on how to overlay tiles on Google maps « reperiendi

  11. Pingback: für die google maps Gruppe – VIENNACAST

  12. Hi there

    This tute was really helpful thanks! I am able to define my zoom levels and cut the tiles. However when I zoom bigger than my map viewport, the map disappears, even though there are tiles cut for this.

    Has anyone else had this issue?

    Thanks for your help

    • Check to make sure that you have that zoom level defined in the JavaScript when you create the gmap. If it’s not defined, even though you have tiles for it, the API will not know to display them.

  13. “Google doesn’t make this any easier by providing less than helpful documentation. Plus, whatever tutorials you find are either too simple or out of date”

    And now we can say the same about this :P But it seems like a nice tutorial, but do you plan on making a updated tutorial, that would be awesome :P trying to make a custom map over a mmo, so only with my own picture xD

  14. Pingback: Enhanced Google Maps « Digitisation Fundamentals & Their Application

Comments are closed.