Get Latitude and longitude of marker in google maps

前端 未结 2 1503
梦谈多话
梦谈多话 2020-12-08 06:06

I\'m using the following code to create a map and attach a marker to it. I\'m also adding a marker listener where I need to get the longitude and latitude of the marker posi

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 06:34

    It s quite simple i think if you want the long and lat coordinates with a long press ...

    First, you have to do GoogleMap.setOnMapLongClickListener(this); and add to the signature of the containing class: implements OnMapLongClickListener

    And here is the code:

    @Override    
    public void onMapLongClick(LatLng point) { 
        Toast.makeText(MainActivity.this, point.latitude+" "+point.longitude, Toast.LENGTH_SHORT).show();
    
    }
    

提交回复
热议问题