Search code examples
google-maps-api-3kmlfitbounds

Google Map Api auto-fit (fitBounds) with complex KML


I have a tool using the Google Maps API. I load KML polygons from a huge KML database, containing all KML for every city in France. Then I merge them to create a complex KML containing multiple cities.

I used to call an old Maps API version, and the auto-fit was automatic: it detected the bounds of my KML file, and then adjusted the map zoom to give the user the best zoom level.

But now, when I arrive into the map, the zoom level is so low that I can't see anything.

It seems that, with the new API version, we have to use the fitBounds() methods, giving to it the min/max bounds that we want...

It is impossible! My KML are loaded from a database, and they can contain thousands of polygons, coordinates, pointers...

How am I suppose to deal with that ? Is there a way (for example with a library such as GeoXML3) to get min and max bounds of a complex KML ?


Solution

  • Ok I checked everything and I found the reason of this behaviour. The fact is that I had an invisible point at another place in the map (invisible because it called a "not found" PNG file). I fixed it and the auto-fit works well. Sorry about that.