![]() Usage: map.Zoom = CalculateGMapZoom(mapa. Return (zoom > maxZoomLevel ? (double)maxZoomLevel: (zoom < minZoomLevel ? (double)minZoomLevel: (double)zoom)) Int pixels = mapSize.Width >= mapSize.Height ? mapSize.Height : mapSize.Width //get the shortest dimmension of the mapĭouble k = (double)pixels * 156543.03392 * Math.Cos(latitude * Math.PI / 180) Static double CalculateGMapZoom(Size mapSize, int coverage, double latitude, double distance, int minZoomLevel, int maxZoomLevel) / Distance to show from this point in meters / Latitude where the point to draw is located / The size of the control (map size in pixels) / Zoom map to fit the desired distance from point Use this function in order to get the best zoom based on your current location and a distance to the point (C# code tested with on VS2022 but zoom levels and algorithm are the same for Google): /// Meters_per_pixel = 156543.03392 * s(latLng.lat() * Math.PI / 180) / Math.pow(2, zoom)įormula is from Chris Broadfoot's comment. A formula for calculating the correct scale based on latitude is: Google Maps uses a Mercator projection so the scale varies substantially with latitude. ![]() It appears that the extra zoom level available for Static Maps is just an upsampled version of the max-resolution image from the Javascript API. Note that these values are for the Google Static Maps API which seems to give one more zoom level than the Javascript API. "Deep zoom" locations: 22-23 (see bkaid's link).Hybrid and satellite maps - the max available zoom levels depend on location. ![]() All raster tiles have the same size, usually 256x256 or 512x512 pixels. There is one tile on the top of the pyramid, then 4 tiles, 16 tiles, etc.
0 Comments
Leave a Reply. |