我写了一个应用程序,显示谷歌地图和我的Android的一些Wi-Fi地方,但它没有正确显示叠加。它只是在大西洋中部某处显示一个覆盖标记,与我的标记没有任何相似之处。也许问题是我设法添加GeoPoint的方式,但我试图改变程序的某些部分,它现在像海洋中的奇怪点一样运行。例如我从GeoPoint中移除了这个标志,它只是将那一个地方移到了阿拉伯,这更靠近我的位置,但仍然很多。它应该在黑山(在意大利附近的亚得里亚海岸)显示标记。如果您有任何帮助,请查看此代码并回答。
package rs.iz.stevy.wifi;
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
public class WiFiKupacicaActivity extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapa= (MapView) findViewById(R.id.Mapa1);
mapa.setBuiltInZoomControls(true);
mapa.setSatellite(true);
List<Overlay> mapOverlays = mapa.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.green);//dodaj neki marker
MapOverlay itemizedoverlay = new MapOverlay(drawable, this);
GeoPoint point = new GeoPoint(19249269,-42444210);
OverlayItem overlayitem = new OverlayItem(point, "Krug", "ESSID:nije utvrdjeno Šifra:ima");
GeoPoint point2 = new GeoPoint(19263582,-42441818);
OverlayItem overlayitem2 = new OverlayItem(point2, "Carine 1", "ESSID:Carine Šifra:nema");
GeoPoint point3= new GeoPoint(19261555,-42442169);
OverlayItem overlayitem3 = new OverlayItem(point3, "Sejdefa", "ESSID:Sejdefa Šifra:ima");
GeoPoint point4= new GeoPoint(19250805,-42440254);
OverlayItem overlayitem4 = new OverlayItem(point4, "Unico", "ESSID:Unico Šifra:ima");
GeoPoint point5= new GeoPoint(19247810,-42441559);
OverlayItem overlayitem5 = new OverlayItem(point5,"Carine 2","ESSID:Carine Šfira:nema");
GeoPoint point6= new GeoPoint(19267099,-42433342);
OverlayItem overlayitem6 = new OverlayItem(point6,"Forma", "ESSID:Forma Šifra:ima");
GeoPoint point7= new GeoPoint(19247948,-42443596);
OverlayItem overlayitem7 = new OverlayItem(point7,"Maxim Caffe", "ESSID:nije utvrdjeno Šifra:ima");
GeoPoint point8= new GeoPoint(19259390,-42449978);
OverlayItem overlayitem8 = new OverlayItem(point8,"Me Gusta","ESSID:nije utvrdjeno Šifra:nema");
GeoPoint point9= new GeoPoint(19263691,-42445312);
OverlayItem overlayitem9 = new OverlayItem(point9,"Pub 013","ESSID:nije utvrdjeno Šifra:nema");
GeoPoint point10= new GeoPoint(19259972,-42441254);
OverlayItem overlayitem10 = new OverlayItem(point10,"Alan Ford","ESSID:nije utvrdjeno Šifra:ima");
GeoPoint point11= new GeoPoint(19263325,-42446926);
OverlayItem overlayitem11 = new OverlayItem(point11,"MNNews- Gimnazija","ESSID:nije utvrdjeno Šifra:nema/login preko web-a");
GeoPoint point12= new GeoPoint(19262810,-42441257);
OverlayItem overlayitem12 = new OverlayItem(point12,"MNNews- Trg Republike","ESSID:nije utvrdjeno Šifra:nema/login preko web-a");
GeoPoint point13= new GeoPoint(19246502,-42442612);
OverlayItem overlayitem13 = new OverlayItem(point13,"MNNews- Rimski trg","ESSID:nije utvrdjeno Šifra:nema/login preko web-a");
itemizedoverlay.addOverlay(overlayitem);
itemizedoverlay.addOverlay(overlayitem2);
itemizedoverlay.addOverlay(overlayitem3);
itemizedoverlay.addOverlay(overlayitem4);
itemizedoverlay.addOverlay(overlayitem5);
itemizedoverlay.addOverlay(overlayitem6);
itemizedoverlay.addOverlay(overlayitem7);
itemizedoverlay.addOverlay(overlayitem8);
itemizedoverlay.addOverlay(overlayitem9);
itemizedoverlay.addOverlay(overlayitem10);
itemizedoverlay.addOverlay(overlayitem11);
itemizedoverlay.addOverlay(overlayitem12);
itemizedoverlay.addOverlay(overlayitem13);
mapOverlays.add(itemizedoverlay);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
编辑:这是覆盖类的代码:
package rs.iz.stevy.wifi;
import java.util.ArrayList;
import android.graphics.drawable.Drawable;
import android.app.AlertDialog;
import android.content.Context;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
public class MapOverlay extends ItemizedOverlay {
private ArrayList<OverlayItem>mOverlays= new ArrayList<OverlayItem>();
private Context mContext;
public MapOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext=context;
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i); }
@Override
public int size() {
return mOverlays.size();
}
//itemizedoverlay.addOverlay(overlayitem);
//mapOverlays.add(itemizedoverlay);
//@Override
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}
答案 0 :(得分:0)
我改变了坐标的位置,这导致了这个错误。 例如:
GeoPoint point = new GeoPoint(19249269,-42444210);
OverlayItem overlayitem = new OverlayItem(point, "Krug", "ESSID:nije utvrdjeno Šifra:ima");
相反,只需用42444210更改19249269
GeoPoint point = new GeoPoint(42444210,19249269);
OverlayItem overlayitem = new OverlayItem(point, "Krug", "ESSID:nije utvrdjeno Šifra:ima");