简体   繁体   English

在Android中使用Google Map V2在触摸的位置添加标记

[英]Add marker on touched location using google map v2 in android

I want to add a Pinpoint on touched location using google maps v2. 我想使用Google Maps v2在触摸的位置添加精确定位。 I just find code using google maps v1 and that doesnt works for me.. 我只是使用Google Maps v1找到代码,因此对我不起作用。

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"));
 }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM