Car*_*s P 2 .net c# xaml windows-phone-8
我正在使用全新的Windows Phone 8 Map控件,但遇到了一个问题:我需要获取地图边界的LocationRectangle,换句话说就是Latitude span和Longitude span.
使用Bing Maps控件,您可以执行以下操作:
LocationRect bounds = map.Bounds;
Run Code Online (Sandbox Code Playgroud)
...但是,这个新控件中似乎没有相关字段.任何人都可以提供帮助,或者我是否需要对各种缩放级别进行反向工程并根据中心点,缩放级别和像素高度/宽度进行处理?
您可以使用视口转换方法,例如:
GeoCoordinate topLeft = yourMapInstance.ConvertViewportPointToGeoCoordinate(new Point(0, 0));
GeoCoordinate bottomRight =
yourMapInstance.ConvertViewportPointToGeoCoordinate(new Point(mapSize.Width, mapSize.Height));
return LocationRectangle.CreateBoundingRectangle(new[] { topLeft, bottomRight });
Run Code Online (Sandbox Code Playgroud)
可能你可以直接使用mapControl实例的renderSize,但为了确保运行时的正确尺寸,我建议你去监听"SizeChanged"事件.并且检查mapsize值不是0或Infiniteis也可能是一个好主意.
| 归档时间: |
|
| 查看次数: |
2871 次 |
| 最近记录: |