本文介绍了Android版的GeoPoint错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void addOverLays(){
String [] coordinates = {"30.084262490272522","31.33625864982605" ,"30.084123015403748", "51.5002" , "-0.1262","31.337149143218994"};
double lat = 30.084262490272522, lat2 = 51.5002,lat3=30.084123015403748;
double log = 31.33625864982605, log2 = -0.1262,log3=31.337149143218994;
p = new GeoPoint((int) (lat * 1E6), (int) (log * 1E6));
p2 = new GeoPoint( (int) (lat2 * 1e6), (int) (log2 * 1e6));
p3 = new GeoPoint( (int) (lat3 * 1E6), (int) (log3 * 1E6));
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.icon);
drawable2 = this.getResources().getDrawable(R.drawable.pushpin);
drawable3 = this.getResources().getDrawable(R.drawable.ballon);
itemizedOverlay = new HelloItemizedOverlay(drawable,this);
itemizedOverlay2 = new HelloItemizedOverlay(drawable2,this);
itemizedOverlay3 = new HelloItemizedOverlay(drawable3,this);
OverlayItem overlayitem = new OverlayItem(p, "Cairo", " over1");
OverlayItem over2 = new OverlayItem(p2, "ulm", "over2");
OverlayItem over3 = new OverlayItem(p3, "offff", "over3");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
itemizedOverlay2.addOverlay(over2);
mapOverlays.add(itemizedOverlay2);
itemizedOverlay2.addOverlay(over3);
mapOverlays.add(itemizedOverlay3);
为什么我不能添加3个项目因
Why can't I add 3 items due to
p = new GeoPoint((int) (lat * 1E6), (int) (log * 1E6));
p2 = new GeoPoint( (int) (lat2 * 1e6), (int) (log2 * 1e6));
p3 = new GeoPoint( (int) (lat3 * 1E6), (int) (log3 * 1E6));
不能使1E6和放大器; 1e6个电子我必须做什么其他的?!!
can't make 1E6 & 1e6 what other I have to do?!!
推荐答案
在可能的有铸造的问题,很难说。尝试使用这个工具的方法:
you might have a casting issue, hard to tell. Try using this utility method:
public static GeoPoint calculateGeoPoint(double latitude, double longitude) {
Double latE6 = latitude * 1E6;
Double lngE6 = longitude * 1E6;
return new GeoPoint(latE6.intValue(), lngE6.intValue());
}
它工作可靠我在测试生产code。
It's worked reliably for me in tested production code.
这篇关于Android版的GeoPoint错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!