Issue
I wrote an application that shows google maps and some wi-fi places for my android but it doesn't show overlays correctly. It just shows one overlay marker somewhere in middle of the Atlantic ocean and that doesn't have any similarities with my markers. Maybe the problem is in the way I managed to add GeoPoint's but i tried to change some parts of program and it ran as now with that strange point in the ocean. For example i removed this sign - from GeoPoint and it just moved that one spot to Arabia which is closer to my location but still far a lot. It should show markers in Montenegro(on the Adriatic coast,near Italy). Please review this code and answer if you know anything helpful.
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;
}
EDIT:Here is the code of overlay class:
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;
}
}
Solution
I changed the places of coordinates and that's causing this error. For example:
GeoPoint point = new GeoPoint(19249269,-42444210);
OverlayItem overlayitem = new OverlayItem(point, "Krug", "ESSID:nije utvrdjeno Šifra:ima");
Instead this, just change 19249269 with 42444210
GeoPoint point = new GeoPoint(42444210,19249269);
OverlayItem overlayitem = new OverlayItem(point, "Krug", "ESSID:nije utvrdjeno Šifra:ima");
Answered By - stevyhacker
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.