Android Custom marker icon - android

I'm working on application with Google maps so i want to define a custom marker for each custom place, For example (gas station- Hotel- Hospital.. ) ! i have a overlays class with the latitude and longitude of many places and i want just how to give a custom icon!

With the new Maps Api Setting the Icon for a Marker is done with the following Code:
MarkerOptions markerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_location));
The icon can not be changed after a Marker was created. To change an icon remove the marker and readd it with a new image.

with the APi v2, you can do (markerObject).setIcon(BitmapDescriptor) to change/set the marker image.

OverlayItem.setMarker seems like the method you're looking for.
Note that there is (or used to be) a gotcha you need to be aware of; you first need to use Drawable.setBounds to set the visible boundaries of the drawable before it can be rendered properly. Some fiddling might be needed to get it to centre; see this answer.

Related

Adding description of marker on google map

I have several markers with different colors, every color is used for specific purpose(like user's location etc). for each color I want to add short description of marker on the map.Is it possible to add short description of color on google map in right side corner?
In your layout file of map you can add any thing apart from MapFragment. but ensure that in your xml add other views after Mapfragment then they will appear above map fragment.

How to set current location indicator behind map markers on MapBox (Z-Order)?

Is it possible to place the MyLocation background drawable behind markers on MapBox Xamarin Android?
The current gps location indicator is default placed above all markers. Is there any way to configure this?
I've also tried to set my current location as a marker, but it looks like the z-order is based on the screen position, and I cant find a way to configure the z-order of Markers.
UPDATE: Missed that this question was about MapBox. The below is just for the Google maps APIs. I suggest checking out MapBox's docs to see if they allow access to the ZIndex property of the underlying marker.
To set the Z-Order of Markers (where map is the GoogleMap instance):
var markerFront = new MarkerOptions();
markerFront.InvokeZIndex(1f); // Set the z-order
markerFront.SetTitle("In Front");
markerFront.SetPosition(new LatLng(lat, lon));
var markerBack = new MarkerOptions();
markerBack.InvokeZIndex(2f); // set the z-order
markerBack.SetTitle("behind");
markerBack.SetPosition(new LatLng(lat-0.0001, lon-0.0001));
map.AddMarker(markerFront);
map.AddMarker(markerBack);
And markerFront will be above markerBack. After thedse are set, though, they will be changed by the OS if you click on markerBack it will be moved to the front. I am not sure if the z-order can be changed after the marker is created, so if you need to keep the z-order when clicking on a marker, I think you would have to remove and re-add the marker with the z-order you want.
I could not find a way (after a very brief search) to change the z-order of the current location marker. Personally I would think you would always want the current location indicator in front anyway.

Google Maps Cluster Item Marker - Update Marker Icon

I'm trying to utilize the clustering from Google Maps Android API utility library. So far its working fine. One problem however arise which I don't see a apparent solution for. If I need to update an marker icon in my map view - how to do this? Since the switch to the clustering approach I don't have the Marker objects anymore and can't simply use setIcon. Also I would need to determine if the target marker is currently in a cluster (in this case it would not make sense to update the icon because it represents the whole cluster)
Found a way in DefaultClusterRenderer using the getMarker method. It seems to return Marker objects for single items so the clusters are not affected.

plot a different marker for each place googlemap v2 android

I have managed to place a marker for each item in my database using their stored title and coordinates.
I am now trying to change the content of each InfoWindow so that it shows information related to each place (other than the title and snippet)also each place have a different icon marker. how to give a custom icon and a different infowindow for each place?
i create the different icons for marker.
the information are loading in format json and the icon marker are also in my database.should i load them or put them in drawable folder.
Google covers most of what you want to do in their Google Maps API v2 documentation.
Info Window Customization and Customizing a MArker have code example how-to's. For your marker icons, are they just a different colour marker or are they completely customized? Storing them in drawable is ok and can be accessed easily using
.icon(BitmapDescriptorFactory.fromResource(R.drawable.your_custom_marker))
when creating/adding the Marker.

How to add information to a marker on the map?

I have a map with markers on it, how to add information to them?
I'm using OverlayItem thing.
I found this, but I'm almost sure that I have seen somewhere solution created by Google.
Well it depends on how much information you need per marker. You can for example set the title of each marker, and you can even display that as text over the marker if you want to. Additionally you can even use snippet which is another attribute of overlay items. Personally, I use the title() and snippet() attributes very often when using maps, but if you need to display more detail, you should go with #Michal's answer of using pop-up balloons for each overlay.
There are quite some posts on pop-up balloons if you're interested here , here and here
Hope this helps.
Which google api are you using? You can put the additional info as an InfoWindow overlay (you can include html there too). And on a marker click show the infowindow with an appropriate content (e.g. html content).
You can basically use any Drawable to put as a marker on the screen. This includes your own made Drawables. Then you can simply use an ItemizedOverlay to show your Drawables on the map.
To your custom drawable you can draw any information in the draw()-method of the Drawable like I did in my Drawable here:
public void draw(Canvas canvas)
{
marker.draw(canvas);
canvas.drawBitmap(image, null, new Rect(-38, -102, 38, -28), null);
}

Categories

Resources