Google Maps Overlays
Asked Answered
M

5

7

I'm trying to find something, preferably F/OSS, that can generate a Google Maps overlay from KML and/or KMZ data.

We've got an event site we're working on that needed to accommodate ~16,000 place markers last year and will likely have at least that many again this year. Last year, the company that had done the site just fed the KML data directly to the gMaps API and let it place all of the markers client side. Obviously, that became a performance nightmare and tended to make older browsers "freeze" (or at least appear frozen for several minutes at a time).

Ideally this server side script would take the KML, the map's lat/lon center, and the map zoom level and appropriately merge all of the visible place markers into a single GIF or PNG overlay.

Any guidance or recommendations on this would be greatly appreciated.

UPDATE 10/8/2008 - Most of the information I've come across here and other places would seem to indicate that lessening the number of points on the map is the way to go (i.e. using one marker to represent several when viewing from a higher altitude/zoom level). While that's probably a good approach in some cases, it won't work here. We're looking for the visual impact of a US map with many thousand markers on it. One option I've explored is a service called PushPin, which when fed (presumably) KML will create, server side, an overlay that has all of the visible points (based on center lat/lon and zoom level) rendered onto a single image, so instead of performing several thousand DOM manipulations client side, we merge all of those markers into a single image server side and do a single DOM manipulation on the client end. The PushPin service is really slick and would definitely work if not for the associated costs. We're really looking for something F/OSS that we could run server side to generate that overlay ourselves.

Maugre answered 6/10, 2008 at 14:33 Comment(0)
H
4

You may want to look into something like Geoserver or Mapserver. They are Google map clones, and a lot more.

You could generate an overlay that you like, and Geoserver(I think mapserver does as well) can give you KML, PDF, png, and other output to mix your maps, or you could generate the whole map by yourself, but that takes time.

Hofmannsthal answered 6/10, 2008 at 14:49 Comment(2)
These look interesting, I'll see if they'll work for our purposes.Maugre
We will defiantly be looking into GeoServer and GeoWebCache!Concourse
Y
2

Not sure why you want to go to a GIF/PNG overlay, you can do this directly in KML. I'm assuming that most of your performance problem was being caused by points outside the user's current view, i.e. the user is looking at New York but you have points in Los Angeles that are wasting memory because they aren't visible. If you really have 16,000 points that are all visible at once for a typical then yes you'll need to pursue a different strategy.

If the above applies, the procedure would be as follows:

  1. Determine the center & extent of the map
  2. Given that you should be able to calculate the lat/long of the upper left and lower right corners of the map.
  3. Iterate through your database of points and check each location against the two corners. Longitude needs to be greater (signed!) than the upper left longitude and less than the lower right longitude. Latitude needs to be less than the upper left latitude (signed!) and greater than the lower right latitude. Just simple comparisons, no fancy calculations required here.
  4. Output the matching points to a temporary KML for the user.
  5. You can feed KML directly into Google Maps and let it map it, or you can use the Javascript maps API to load the points via KML.

It might not solve your exact problem here, but for related issues you might also look into the Google Static Maps API. This allows you to create a static image file with placemarkers on it that will load very quickly, but won't have the interactivity of a regular Google map. Because of the way the API is designed, however, it can't handle anywhere near 16,000 points either so you'd still have to filter down to the view.

Yaw answered 6/10, 2008 at 15:29 Comment(2)
The plan is to have a national level view showing the full data set, so yes, we really need to make all of the points appear concurrently. We will allow zooming and can work with zoom level view radiuses to use smaller KML data sets as the user drills down, but we need to be able to display all.Maugre
I would adopt a strategy of finding clusters of events that you can reduce to one pushpin on the national map that then hyperlinks to a view of just that city. The method would be similar but you'd need to use a version of the Haversine formula to find points that were within "x" miles.Yaw
S
1

I don't know how fare you are with your project but maybe you can take a look at GeoDjango? This modified Django release includes all kinds of tools to store locations; convert coordinates and display maps, the easy way. Offcourse you need some Python experience and a server to run it on, but once you've got the hang of Django it works fast and good.

If you just want a solution for your problem try grouping your results at lower zoom levels, a good example of this implementation can be found here.

Stamp answered 6/10, 2008 at 14:57 Comment(1)
I don't know that Django/Python would be a deal breaker, but I haven't ever worked with either technology before. The core of this site is going to be don in Drupal, per the client's request, so a PHP backend would be idea. I'll check this option out however.Maugre
F
0

This is a tough one. You can use custom tilesets with Google Maps, but you still need some way to generate the tiles (other than manually).

I'm afraid that's all I've got =/

Floorman answered 6/10, 2008 at 14:47 Comment(1)
yes, that's certainly my thinking in having the overlay, but what I'm specifically hoping for is something server side that will generate the overlay based on KML, center lat/lon, and zoom level.Maugre
I
0

OpenLayers is a great javascript frontend to multiple mapping services or your own map servers. Version 2.7 was just released, which adds some pretty amazing features and controls.

Insomuch answered 6/10, 2008 at 15:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.