Google Maps Bounds and Zoom
-
Google maps KML zoom and centering: I need to inventory a variety of polygons and points on a single map, some from a database and some from KML files. Can you help point me in the right direction? I have a home-grown CMS with some limited Google map functionality. I now allow folks to upload KML files, and display them in their map. They can also add points manually via a CMS interface. All this works well as far as displaying on the map. However, I lack the requisite knowledge on inventorying the entire set of items being displayed and setting the zoom and center so that everything is visible at the initial rendering. Before I added the KML file linking ability, to find the zoom and center when outputting the map I added each point to the "bounds" array, and then: map.setZoom(map.getBoundsZoomLevel(bounds)); map.setCenter(bounds.getCenter()); And I know that if all I am displaying is a single KML file, I could simply use: kmldata.gotoDefaultViewport(map); What I think I need to do to work with multiple KML files and individually added markers: parse the coords in the KML file(s) and add every one to the "bounds" array. Problem is, I'm not sure how best to do that. What would you parse the KML, if that's what I need to do?
-
Answer:
This question might find a lot more audience at http://gis.stackexchange.com/
maxwelton at Ask.Metafilter.Com Visit the source
Other answers
Does your backend database support GEOS spatial functions? If so, you can find the centre with something like Centroid(Envelope(Union( ... all your stuff ... ).
scruss
Related Q & A:
- Is it possible to make bend with google maps polyline?Best solution by stackoverflow.com
- How to change info Window style in Google Maps API?Best solution by Stack Overflow
- How often does google maps update?Best solution by Web Applications
- When is Google updating Google Maps?Best solution by en.wikipedia.org
- How to open google latitude on iphone from google maps?Best solution by seroundtable.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.