Windows Phone的 - 获得距离缩放级别 [英] Windows Phone - get zoom level from distance
本文介绍了Windows Phone的 - 获得距离缩放级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不擅长数学,请帮助我。我有米的距离,我需要计算缩放级别和中心从该映射。我该怎么办呢?我开始用这个,但现在我完全地失去了:
I am not good at math so please help me with this. I have distance in meters and I need to calculate zoom level and center to map from this. How can I do that? I started with this but now I am completly lost:
var sCoord = new GeoCoordinate(startPoint.X, startPoint.Y);
var eCoord = new GeoCoordinate(latitude, longitude);
var distance = sCoord.GetDistanceTo(eCoord);
感谢
Thanks
推荐答案
如果我没有低估你,你可以通过下面的代码
If I understated you correctly, you can achieve the goal by using the following code
var start = ...;
var finish = ...;
// Calculate center
var center = new GeoCoordinate((start.Latitude + finish.Latitude) / 2,
(start.Longitude + finish.Longitude) / 2);
var width = Math.Abs(start.Longitude - finish.Longitude);
var height = Math.Abs(start.Latitude - finish.Latitude);
Map.SetView(new LocationRectangle(center, width, height));
这篇关于Windows Phone的 - 获得距离缩放级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文