计算纬度经度和纬度钛的地图[Android] [英] Calculate latitudeDelta and longitudeDelta in titanium maps [Android]

查看:137
本文介绍了计算纬度经度和纬度钛的地图[Android]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在显示从当前位置到其他位置的路线。距离为每次都不一样。我能否根据距离计算纬度的经度值和经度纬度,并根据这个值缩放地图?如果是的话,怎么可能呢?



预先感谢!

解决方案

增量值越小,地图上的缩放越近。这意味着0.01会放大更多,而delta(纬度,经度)为0.1。由于这些值在regions参数中是硬编码的,我建议使用一个可以动态填充latitudeDelta的函数:&经度Delta:基于距离。因此,如果距离更远,您可以为delta的其他较小值获得更高的值。



这是一个这样的函数:

 函数distanceToZoom(r){
var w = myMapInstance.getSize()。width;
var d = r * 2;
var distance = [你可以在这个数组中放置距离];
var z = 20,m;
while(distance [ - z]){
m = distance [z] * w;
if(d break;
}
}
return z;

$ / code>

到相应的增量值:
$ b $ (假设)
0.0001 10
0.001 100
0.01 1000
0.1 10000
1 10000

希望这有助于!!


I need a help in showing the correct zoom level in Titanium maps for Android.

I am showing the route from current location to some other location.The distance is different every time. Can it be possible that I calculate the values of latitudeDelta and longitudeDelta based on the distance and show the map zoomed up according to that? If yes, how could it be possible?

Thanks in advance!

解决方案

As the the documentation states the smaller the delta value, the closer the zoom on your map. That means 0.01 will zoom in more as compared to 0.1 for delta (latitude, longitude). As these values are hardcoded in the regions parameter, I would recommend is to use a function that would dynamically populate latitudeDelta: & longitudeDelta: based on the distance. So if the distance is more you can have a higher value for delta's else lesser values.

Here is one such function:

function distanceToZoom( r ){
    var w = myMapInstance.getSize().width;
    var d = r * 2;
    var distance = [you can put distances in this array];
    var z = 20, m;
    while( distance[--z] ){
        m = distance[z] * w;
        if( d < m ){
            break;
        }
    }
    return z;
} 

To corresponding delta values:

delta distance in miles (Supposedly)
0.0001  10
 0.001  100
  0.01  1000
   0.1  10000
   1    10000

Hope this Helps!!

这篇关于计算纬度经度和纬度钛的地图[Android]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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