获取MapControl边框的距离(以度为单位) [英] Get distance of MapControl border in degrees

查看:113
本文介绍了获取MapControl边框的距离(以度为单位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MapControl,想知道当前在x和y轴上显示多少度.

I have a MapControl and would like to know how many degrees are currently shown on the x and y axes.

第一个示例:

x轴(经度)上显示360度

360 degrees are shown on the x axis (longitude)

〜90度显示在y轴(纬度)上

~90 degrees are shown on the y axis (latitude)

(缩放级别为3.2,最大可缩放)

(The zoom level is 3.2 and it's max zoomed out)

第二个例子:

〜x轴上的220度(经度)

~220 degrees on the x axis (longitude)

y轴(纬度)180度

180 degrees on the y axis (latitude)

(缩放级别:1.7;最大缩小)

(zoom level: 1.7; max zoomed out)

我尝试使用以下代码计算x轴上的当前度:

I tried calculating the current degrees on the x axis using following code:

double dist = 360 * Math.Pow(0.5, macSurrounding.ZoomLevel - 1);

但是它不起作用,因为缩放级别很奇怪...

but it doesn't work, because the zoom level is just strange...

推荐答案

您应使用MapControl的

You should use the MapControl's GetLocationFromOffset method to calculate the geographic coordinates of the south-east and north-west corner points of the current map viewport. The width and height of the viewport would be the latitude and longitude differences of these points.

Geopoint northEast;
Geopoint southWest;

map.GetLocationFromOffset(new Point(map.ActualWidth, 0), out northEast);
map.GetLocationFromOffset(new Point(0, map.ActualHeight), out southWest);

var width = northEast.Position.Longitude - southWest.Position.Longitude;
var height = northEast.Position.Latitude - southWest.Position.Latitude;

这篇关于获取MapControl边框的距离(以度为单位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆