C.Z
C.Z

Reputation: 41

Add marker on touched location using google map v2 in android

I want to add a Pinpoint on touched location using google maps v2. I just find code using google maps v1 and that doesnt works for me..

Upvotes: 1

Views: 1376

Answers (1)

Pradeep Kumar
Pradeep Kumar

Reputation: 877

public class YourActivity extends FragmentActivity implements OnMapClickListener {
   private GoogleMap mMap;
  @Override
  protected void onCreate(Bundle saveInstanceState) { 
    super.onCreate(saveInstanceState);
    ...
    my_map.setOnMapClickListener(this)        
    ...
}

public void onMapClick (LatLng point) {
    // Do Something
   mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
   mMap.addMarker(new MarkerOptions()
    .position(point)
    .title("TouchPoint"));
 }
}

Upvotes: 7

Related Questions