Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace default Android Maps API v2 Change MyLocation icon

I would like to replace the default icon that Android Maps V2 uses for 'My Location' with my own image. I've created my own tile provider that brings in a few maps which are predominantly blue and as such the default My Location icon, the little blue arrow, is very hard to see.

Previously I would have just overridden the draw method of the MyLocationOverlay, but there doesn't seem to be one in the new API.

I also need the icon to be able to rotate, the same way that the arrow does depending on which way you are facing. So I can't just use a normal marker. Basically I just need to create a custom image for that arrow.

like image 665
Gyroscope Avatar asked Feb 12 '13 05:02

Gyroscope


People also ask

How do I change the map style in Android?

To style your map, call GoogleMap. setMapStyle() passing a MapStyleOptions object that contains your style declarations in JSON format.

How do I change my default location on Google Maps Android?

Look to the top-left corner of the map, and click the three horizontal menu bars. From the options, select Your places. Next, click Home. Type the name of the location you want to set as your home address in the address field.


1 Answers

my simple solution way is just disable "my location" of Google map

and create ImageView on Map with my icon then capture ImageView with

onClick and getMyLocation , animateCamera in onClick

 this.mGoogleMap.getUiSettings().setMyLocationButtonEnabled(false);  this.mGoogleMap.setMyLocationEnabled(true); 

.

@Override public void onClick(final View v) {      Location location = this.mGoogleMap.getMyLocation();          if (location != null) {              LatLng target = new LatLng(location.getLatitude(), location.getLongitude());             CameraPosition position = this.mGoogleMap.getCameraPosition();              Builder builder = new CameraPosition.Builder();             builder.zoom(15);             builder.target(target);              this.mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(builder.build()));            }     } 
like image 79
Intathep Avatar answered Sep 21 '22 21:09

Intathep