Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i add markers on google maps to users selection on map
    primarykey
    data
    text
    <p>I am trying to add a custom marker to the users selection on a map. this it the code i have now but seem to get a error under "add" at "mapView.getOverlays().add(mapView);" I want the user to select various icons and place them on the map where they are.</p> <pre><code>import java.util.List; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; 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; import android.view.MotionEvent; public class MainActivity extends MapActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MapView mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); List&lt;Overlay&gt; mapOverlays = mapView.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker); CustomOverlay itemizedoverlay = new CustomOverlay(drawable, this); GeoPoint point = new GeoPoint((int)(24.0110 * 1E6), (int)(31.4850 * 1E6)); MapController controller = mapView.getController(); controller.setCenter(point); controller.setZoom(11); OverlayItem overlayitem = new OverlayItem(point, "Hello!", "Guess where I am?") itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); } public boolean onTouchEvent(MotionEvent event, MapView mapView) { if (event.getAction() == 1) { GeoPoint p = mapView.getProjection().fromPixels((int) event.getX(), (int) event.getY()); MainActivity Overlay = new MainActivity(); mapView.getOverlays().add(mapView); mapView.invalidate(); GeoPoint point = mapView.getProjection().fromPixels((int) event.getX(),(int) event.getY ()); Drawable srcdrawable = getApplicationContext().getResources().getDrawable (R.drawable.icon); CustomOverlay srcitemizedOverlay = new CustomOverlay(srcdrawable, getApplicationContext ()); OverlayItem srcoverlayitem = new OverlayItem(p, "Hello!", "This is your Location."); srcitemizedOverlay.addOverlay(srcoverlayitem); mapView.getOverlays().clear(); mapView.getOverlays().add(srcitemizedOverlay); } return false; } @Override protected boolean isRouteDisplayed() { return false; } } </code></pre> <p>Am I on the write track? and is my code correct? And can someone maybe have a link to a tutorial on how to do this.</p>
    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.
 

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