Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get screen center location of google map?

I want to create a map with static marker to always show the location of center of screen. I've created a marker in layout with drawable image in the center. Now I need to get the center location coordinates and convert them to address. afterwards show the selected location in a text view as my selected location. Need help

like image 732
MANCHAI Avatar asked Jul 27 '15 07:07

MANCHAI


People also ask

Can Google Maps display coordinates?

Get the coordinates of a place On your computer, open Google Maps. Right-click the place or area on the map. This will open a pop-up window. You can find your latitude and longitude in decimal format at the top.


1 Answers

You can get center point of map at any time by calling this function on your GoogleMap variable instance

mMap.getCameraPosition().target 

Now if you want to get center point everytime map is changed then you need to implement OnCameraChangeListener listener and call the above line to get new center point.

Update: OnCameraChangeListener has been replaced with OnCameraMoveStartedListener, OnCameraMoveListener and OnCameraIdleListener listeners. Use the one that suits your use case.

like image 198
Sharj Avatar answered Oct 06 '22 23:10

Sharj