tags:

views:

366

answers:

3

Just to be clear from the start, I've never used Google maps in any of my programs/projects, so I have a little knowledge on this matter. Also, I found some other posts in SO about Google maps, but I'm not sure if any of these really helps in my situation.

What I want to do is add another map above the already existing Google map. The new overlay map would have some degree of transparency in order for the original Google map to be visible too. Something like this: http://crf.casa.ucl.ac.uk/screenRoute.aspx?s=386&d=105&w=False

How can I do this? What technologies should I look into? I'm a Java developer, but any answer in any language would be really helpful.

+1  A: 

I suggest downloading the open-source tool MapTiler (for Windows and Mac OS X).

You would have to use the GMapType object to define your own custom map. MapTiler will automate the tiling process for you, and in addition, once the tiling process is finished, it will generate a simple HTML viewer. It will also include a custom control to change to opacity of your overlay from 0 to 100%.

Custom Map Tile Overlays are quite an advanced topic in the Google Maps API (even the documentation will warn you in red about this). However, I am sure you will be able to use and understand the deliverable HTML viewer of MapTiler.

The following is a sample of what MapTiler is able to produce (note the opacity slider on the top-right):

Daniel Vassallo
This is a very good solution. But I would prefer to do this with code, dynamically, since I don't have one static map that I want to use as overlay, but it's time is a different one.
Alex
Doing that dynamically is quite a complicated process. You would need to find a way to define and dynamically tile your overlay into 256x256 tiles and display the relevant tiles on the map given the current coordinates, and you will need to determine yourself how to reference and display tile images. Also note that MapTiler takes about a couple of hours to tile a 400km squared custom map for all zoom levels on my iMac MB419.
Daniel Vassallo
Obviously one option is to check the MapTiler source code, and see if you can adapt the tiling algorithms to your application.
Daniel Vassallo
+1  A: 

It depends on how detailed/large the overlay needs to be. MapTiler is fantastic if you need to be able to zoom in to a very detailed overlay, but if your overlays don't need to be quite so huge, I'd recommend using a GGroundOverlay. It would be pretty easy to change dynamically. Here is Google's demo.

As far as MapTiler goes - if you have a set of overlays you want to change dynamically, you can generate the tiles for all of the overlays, and then easily switch between them. But if you're creating the overlays dynamically, you'll probably need to implement a tile server. Check out Mapnik and TileCache.

Chris B
I think that GGroundOverlay will do what I want! Actually, it's my fault because I didn't formulate the question in a right way for you to fully understand what I'm looking for. What I want to create is some kind of game that will be played on a real map, so I want to show on an existing Google map some sort of houses, castles, etc. If you have any other suggestions please share them with me. Thank you :)
Alex
A: 

I recommend another easy solution: OpenLayers.

See: http://openlayers.org/dev/examples/

Filter for "google", open link in new windows, and look how simple the code is.

OpenLayers is JavaScript API (which can be used instead of Google's API), but it can use many layers. You can mix:

  • google maps
  • vector objects
  • raster images
  • WMS objects - GeoServer, MapServer, Mapnik tiles (like these from OpenStreetMap)
rafalmag