Android Google Maps API - show marker up to certain zoom - android

I am trying to show a marker similar to the ones circled in red in the picture below. The way they behave is that they are visible up to a certain zoom, and disappears when zoomed out beyond that. I can probably programmatically hide them past a certain zoom, but I was wondering if Google Maps Android API had support for these special markers built in. Thanks.

The closest thing to a built-in feature for showing/hiding markers at different zoom levels is the marker clustering implementation in the android-maps-utils library.
See this Activity in the demo app in particular for an implementation of clustered markers with custom icons:
https://github.com/googlemaps/android-maps-utils/blob/master/demo/src/com/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity.java
The result can be seen below - on the left, several icons are hidden and clustered into a single "parent" icon when zoomed out, and the parent icon has a count in the middle for the number of clustered children. When you zoom in (right), you can see that these children icons are unclustered and shown separately as their own individual icons.

This can be easily done using zoom listeners and setVisible functions.
Checkout this SO post for coding details:
How to make a marker appear or disappear based on zoom level on Google Maps v2

The following code can be used for a custom marker:
Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.title("Melbourne")
.snippet("Population: 4,137,400")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker)));

Related

How to place a marker on top of my location layer?

I have issue with drawing custom marker on top of marker from my location layer using GoogleMaps for Android.
Documentation doesn't provide any information how to do that.
Setting big value for markers zIndex doesn't help.

How to know if markers on the map touch each other

I am building an application which uses Google Maps. When displaying the map, I'm also adding markers. Is there a way to see if there are 2 markers that touch each other, meaning if a part of a marker is on top of another marker? My goal is to be able to find that out and then make them a single bigger marker instead of 2 different markers.
The answer should depend somehow on the marker's icon size and the current map zoom since if I zoom out, there's a bigger chance they might overlap.
There seem to be a library made by Google which clusters a set of markers together automatically when they are close to one another.
The library is the marker clustering utility and instruction can be found here:
https://developers.google.com/maps/documentation/android-api/utility/marker-clustering

How to make a Custom marker on google maps disappear if it is not in focus

Some of the markers in google maps appear when zoomed in. However, when a user drag the map into a different place, the marker disappears, and when you drag it again on the previous place, the marker starts to animate in front of you (I hope you are getting what I'm trying to say). I want to know if there is such a way to do that. Thanks.
The same thing happens in Google Maps Android API v2 on street names, parks, etc.
There is no support for marker transparency as of this writing. You will have to code it yourself: posting to Handler until the animation finishes and setting new icon every "frame" with increasing opacity.

Label at the top of the marker in google maps api v2

One more problem while switching to the maps api v2.
This is an ugly representation of what i want to achieve.
Edit1. There can be several markers, every marker with its own label. All markers and labels are shown simultaneously.
As you can see there is a label with some information at the top of the marker.
While using api v1 it can easily be done with drawing marker and label on Overlay.
How can I implement it using api v2?
The first idea is to render marker(red) and label(black) to one bitmap and set it as marker. But it will significantly increase marker area(red rectangle) and with this marker limitation gives me real headache with user to map interraction realisation.
The second idea is to use GroundOverlay, but at first glance, it is not designed for this purpose.
Edit2 Here is similar question, solution, like in the first idea, is to use both marker and label as single marker bitmap, created from view.
Have a look at a library I am working on:
googlemaps/android-maps-utils
You can use the BubbleIconFactory to achieve this:
IconGenerator factory = new IconGenerator(this);
Bitmap icon = factory.makeIcon("11:15 1.08.2013");
mMap.addMarker(new MarkerOptions().position(...).
icon(BitmapDescriptorFactory.fromBitmap(icon)));
This is much simpler to do on Android Maps v2. Please take a look at the official documentation here: https://developers.google.com/maps/documentation/android/marker
It is called Info Window. By default, an info window is displayed when a user taps on a marker and if the marker has a title set

How to make a TileOverlay cover the text of the covered map?

I have an app that use the old google map API and add a layer over the map to display a more precise map of my own over the map.
I'm trying to do this in the API v2 using the TileOverlay but the text of the google map are displayed over my tiles.
Here are 2 screenshots, one with the map, and one with the map with an overlay (just based on the API demo)
I tried to add a big Z-Index to the tiles without any results.
Is there any way to really cover the map with custom tiles ?
The reason why you keep seeing the labels, is that in google maps v2 the labels are rendered locally instead of being part of tile bitmaps. The benefit of this, is that you can rotate the map and still have the labels without rotation for easy reading.
Solution
The only solution I know so far is to disable the map base layer using setMapType(MAP_TYPE_NONE). However, this may have the undesireble effect of also disabling parts of the map that are not being covered by your overlay.
Regards.

Categories

Resources