Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach a flexible marker on map something like Uber and Lyft?

How to attach a flexible marker on map something like Uber and Lyft ? am using Google maps v2.

Basically, i want to display a marker on map while the position of the marker is changed upon moving the map.

edited:

Ok i solved my problem.

first : add an imageview to the same layout and position equal to center. second: to get the coordinate of the center of the map use the following approach

1- get viewgroup ( FrameLayout ) in my case where the map fragment is located.

FrameLayout myContainer = (FrameLayout) findViewById(R.id.content_frame);
int mapHeight = myContainer.getHeight();
int mapWidth = myContainer.getWidth();

2- use setOnCameraChangeListener and on camera change get the coordinates:

LatLng center = mMap.getCameraPosition().target;
like image 368
mhdtouban Avatar asked Feb 08 '14 23:02

mhdtouban


1 Answers

edited:

Ok i solved my problem.

first : add an imageview to the same layout and position equal to center. second: to get the coordinate of the center of the map use the following approach

1- get viewgroup ( FrameLayout ) in my case where the map fragment is located.

FrameLayout myContainer = (FrameLayout) findViewById(R.id.content_frame);
int mapHeight = myContainer.getHeight();
int mapWidth = myContainer.getWidth();

2- use setOnCameraChangeListener and on camera change get the coordinates:

LatLng center = mMap.getCameraPosition().target;
like image 184
mhdtouban Avatar answered Oct 08 '22 23:10

mhdtouban