Hi Esa, Thanks a lot for your help. I quote you here the code I meant on that thread:
/** * Utility function to calculate the appropriate zoom level for a * given bounding box and map image size. Uses the formula described * in the Google Mapki (http://mapki.com/). * * @param bounds bounding box (GBounds instance) * @param mnode DOM element containing the map. * @return zoom level. */ function best_zoom(bounds, mnode) { var width = mnode.offsetWidth; var height = mnode.offsetHeight; var dlat = Math.abs(bounds.maxY - bounds.minY); var dlon = Math.abs(bounds.maxX - bounds.minX); if(dlat == 0 && dlon == 0) return 4; // Center latitude in radians var clat = Math.PI*(bounds.minY + bounds.maxY)/360.; var C = 0.0000107288; var z0 = Math.ceil(Math.log(dlat/(C*height))/Math.LN2); var z1 = Math.ceil(Math.log(dlon/(C*width*Math.cos(clat)))/Math.LN2); return (z1 > z0) ? z1 : z0; I need to calculate the center of the map and the appropiate zoom/ scale on server-side because I want to show aproximately 50 markers and 50 polylines, and until I have not processed all the JSON file and painted all the markers over the map I can't get the center and appropiate zoom/scale. Maybe I could loop the JSON first, only obtaining lat and lng of each marker, and center the map, then, afterwards, paint all the markers. The main important thing I want to get is the visual effect for the final user: first of all the map is loaded, with all its tiles, then, afterwards, all the markers/polylines are painted over the map. On 1 nov, 00:55, Esa <[EMAIL PROTECTED]> wrote: > On Oct 31, 6:45 pm, Alejo83 <[EMAIL PROTECTED]> wrote: > > > Ok, thank you very much for your help. Finally I found an algorithm > > through these groups that goes quite well. > > > The code I found is here: > > >http://groups.google.com/group/Google-Maps-API/browse_thread/thread/9... > > Two things: > > - I don't see any 'algorithm' on that thread > - I don't really get why you want to do that on server side --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
