0
votes

I have to use Google dynamic map to search a location, scroll, zoom, etc and then take a screenshot of the map. Due to license restriction, I cannot take a screenshot (GMap.Snapshot(this)). So it was decided to download an image from google static map

When the user wants to switch from map dynamic mode to static map, he clicks a button and I take center latitude and longitude, zoom level and map size (it's xamarin android)

        {
            CenterLatLng = new double[] { GMap.CameraPosition.Target.Latitude, GMap.CameraPosition.Target.Longitude },
            ZoomLevel = (int)GMap.CameraPosition.Zoom,
            Type = GMap.MapType,
            MapSize = new int[] { MapFragment.View.MeasuredWidth, MapFragment.View.MeasuredHeight }
        };

with this parameters i will try to download a static map

        int scale = 2;
        var url = $"https://maps.googleapis.com/maps/api/staticmap?center={myobject.CenterLatLng[0]},{myobject.CenterLatLng[1]}&zoom={myobject.ZoomLevel}&size={myobject.MapSize[0] / scale}x{myobject.MapSize[1] / scale}&scale={scale}&maptype=satellite&format=png&key=xxxxxxxx";

but downloaded static map seems to have a different zoom from dynamic Map

Here a screenshot of the Dynamic Map displayed before than switching to Static map

Here a screenshot of the Static Map displayed after

how can I fix that difference between dynamic map zoom and static map zoom?

1

1 Answers

0
votes

how can I fix that difference between dynamic map zoom and static map zoom?

I think the issue is caused by the size you set in the url size={myobject.MapSize[0] / scale}x{myobject.MapSize[1] / scale}. You could create a new variable to divide the MapSize instead of using scale to change the size.