Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know what exactly you are trying to do here, but I can see some errors:</p> <ul> <li>class declaration is wrong (you have to use MapActivity not Activity):</li> </ul> <blockquote> <p>public class GpsoverlayActivity extends MapActivity</p> </blockquote> <ul> <li><p>about gp, you didn't put a value in it, insert any latitude and longitude like this:</p> <pre><code>GeoPoint gp= new GeoPoint((int)(26.2*1.0E6), (int)(52.6*1.0E6)); </code></pre></li> </ul> <p>if you are trying to marker on the map I suggest you create another class extends ItemizedOverlay like this structure:</p> <pre><code>public class MapViewItemizedOverlay extends ItemizedOverlay { private ArrayList&lt;OverlayItem&gt; mOverlays = new ArrayList&lt;OverlayItem&gt;(); private Context mContext; public MapViewItemizedOverlay(Drawable defaultMarker, Context context) { super(boundCenterBottom(defaultMarker)); // TODO Auto-generated constructor stub mContext = context; } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { // TODO Auto-generated method stub return mOverlays.size(); } public void addOverlay(OverlayItem overlay) { mOverlays.add(overlay); populate(); } @Override public boolean onTap(int index) { //get the marker on the map from here OverlayItem item = mOverlays.get(index); OverlayItem item=getItem(i); GeoPoint geo=item.getPoint(); Point pt=map.getProjection().toPixels(geo, null); String message=String.format("Lat: %f | Lon: %f\nX: %d | Y %d", geo.getLatitudeE6()/1000000.0, geo.getLongitudeE6()/1000000.0, pt.x, pt.y); Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); return true; } </code></pre> <p>and use it like this in the MapActivity:</p> <pre><code>MapView mapView = (MapView) findViewById(R.id.mapview); MapController mc = mapView.getController(); List&lt;Overlay&gt; mapOverlays = mapView.getOverlays(); //add any icon here for the marker Drawable drawable = MainActivity.this.getResources().getDrawable(R.drawable.icon); MapViewItemizedOverlay itemizedOverlay = new MapViewItemizedOverlay(drawable,this); //insert any lat and lng as integers here GeoPoint point1 = new GeoPoint(lat,lng); OverlayItem overlayitem1 = new OverlayItem(point1, "Info", "You are here!" ); itemizedOverlay.addOverlay(overlayitem1); mapOverlays.add(itemizedOverlay); mc.animateTo(point1); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload