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.
To style your map, call GoogleMap. setMapStyle() passing a MapStyleOptions object that contains your style declarations in JSON format.
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.
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())); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With