[英]Android Google Map: Dynamic Map zoom Level vs Static Map Zoom Level
I have to use Google dynamic map to search a location, scroll, zoom, etc and then take a screenshot of the map. 我必须使用Google动态地图搜索位置,滚动,缩放等,然后拍摄地图的屏幕截图。 Due to license restriction, I cannot take a screenshot (GMap.Snapshot(this)).
由于许可证限制,我无法拍摄屏幕截图(GMap.Snapshot(this))。 So it was decided to download an image from google static map
因此决定从Google静态地图下载图片
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) 当用户想要从地图动态模式切换到静态地图时,他单击一个按钮,然后获取中心纬度和经度,缩放级别和地图大小(这是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? 如何解决动态地图缩放和静态地图缩放之间的差异?
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}
. 我认为问题是由您在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. 您可以创建一个新变量来划分
MapSize
而不是使用scale
来更改大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.