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个项目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我还需要做什么?!!
答案 0 :(得分:1)
你可能有投射问题,很难说。尝试使用此实用程序方法:
public static GeoPoint calculateGeoPoint(double latitude, double longitude) {
Double latE6 = latitude * 1E6;
Double lngE6 = longitude * 1E6;
return new GeoPoint(latE6.intValue(), lngE6.intValue());
}
在测试的生产代码中,它对我来说是可靠的。