How to change the location icon in the Api Google Maps on Android

2

How can I change the blue circle icon of the default location in the Google Maps app to an icon made by me in Android?

!

    
asked by Aruro deGyy 19.06.2017 в 16:36
source

2 answers

4

For a native application using google maps, the marker is simply assigned a different icon.

One of the MarkerOptions options is precisely < a href="https://developers.google.com/android/reference/com/google/android/gms/maps/model/MarkerOptions.html#icon(com.google.android.gms.maps.model.BitmapDescriptor) "> .icon () :

MarkerOptions markerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));

You can also assign an icon directly to the Marker using setIcon() :

Marker m;
m = map.addMarker(new MarkerOptions().position(new LatLng(valueLat, valueLng)));
m.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker));

the image of the marker can be saved inside the folder /drawable

With this method you can define custom icons for your bookmarks:

    
answered by 19.06.2017 / 17:09
source
1

You have to define the marker to use, an example:

var marker = new google.maps.Marker({ 
    map: map, 
    position: position, 
    icon: 'images/mi-marcador.png'
}); 
    
answered by 19.06.2017 в 16:53