Android Maps Utils: How to change default GoogleMap clustering zoom level - android

Hao, stackoverflow!
I'm using Android Maps Utils to cluster markers, it's a little bit tricky, but generally ok.
Map Utils has some default value, on which zoom level it splits one cluster to several clusters or markers. I just need to do it earlier i.e. i need to start split items on bigger zoom level rather then default value.
I think it's not about shoudRenderAsCluster(cluster), cause this callback called already with splitted clusters after this default zoom level.
I've tried GridBasedAlgorithm (really strange behavior when zooming out) and NonHierarchicalDistanceBasedAlgorithm (it seems default).
Thanks!

Related

Android Studio Google Maps Clustering

I have 30 000 Markers inside my map and i tried Cluestering them like Google,up to here all good.
The problem is when i zoom a specific area the markers unclustered not only inside that area but in all the maps and when i unzoom all markers render on my map slowing down
i also have the same problem, showing 32k markers. they said to decide a zoom value where clustering is disabled in the Renderer shouldRenderCluster something overridden method. but i still think the clustering has limitations. i dont mind if max zoom doesnt decluster the markers. the important thing is that when they get clustered, it shouldnt happen like what you showed above.

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

Mapbox for Android: Change map input based on current zoom level

I am adding a large amount of GeoJSON data into Mapbox in an Android app. This makes scrolling through the map very slow on higher zoom levels. For this reason I would like to change the input data based on the current zoom level. I looked for a function like getCurrentZoomlevel(), but all I could find was a getMaxZoomLevel() function in the MapView class and this only gives my the maximum possible zoom level. Is there a function that I can call which gives me the current zoom level?
For this solution to work, I would also need to remove and add certain polygons dynamically based on the zoom level. Is it possible to remove polygons without reloading the entire map?
Starting with 4.0.0 of the Mapbox Android SDK, interaction with the map happens using the MapboxMap object, not the MapView. It sounds like you are trying to add a zoom listener which doesn't exist but a onCameraChangeListener does and from that you can check the zoom level.
mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
#Override
public void onCameraChange(CameraPosition position) {
...
if (position.zoom < 12) {
...
}
}
});
If your GeoJSON file is large and you are trying to draw polygons/polylines you might want to have a look at the Style API we will be introducing in 4.2.0. It allows you to add geojson layers and style them. If you are interested I'd recommend taking a look at the examples found in the Mapbox Android Demo App. This Github issue shows off a bunch of the examples I added.
EDIT: forgot to mention to remove polygons or polylines from the map you have a few options. Either use mapboxMap.removeAnnotations(); to remove all annotations from the map or mapboxMap.removePolygon(); to remove a polygon for example. removePolygon takes in a Polygon object which you'll need to assign when adding the polygon to the map:
Polygon polygon = map.addPolygon(new PolygonOptions()
.addAll(<List of points making up polygon>)
.setFillColor(color));

Android Is it possible to change the appearance of the map in the google maps API

I have been searching in the documentation and throughout google. I would like to know if it is possible to place an image over the map the api comes from to use something else as a visual but with the maps gps functionality. Does anyone know if this is possible?
You can use two types of Overlays:
TileOverlays (reference)
A TileOverlay defines a set of images that are added on top of the base map tiles. You can also use tile overlays to add extra features to the map by providing transparent tile images. You need to provide the tiles for each zoom level that you want to support. If you have enough tiles at multiple zoom levels, you can supplement Google's map data for the entire map.
GroundOverlay (reference)
A ground overlay is an image that is fixed to a map. Unlike markers, ground overlays are oriented against the Earth's surface rather than the screen, so rotating, tilting or zooming the map will change the orientation of the image. Ground overlays are useful when you wish to fix a single image at one area on the map. If you want to add extensive imagery that covers a large portion of the map, you should consider a Tile overlay.

Google Map doesn't zoom out very much

I have this map (supportMapFragment) and it doesn't zoom out more than this.
I remember that sometime ago I was able to zoom out till see the whole planisphere, but now I can't even see a continent!
The only thing I've changed is to use SupportMapFragment instead of MapFragment (because it's inserted in a SlidingPaneLayout, that wants support fragments). It's possibile that support map isn't able to zoom out more than this?
Thank you!
This is by design you cannot see the whole map, but it was already requested on gmaps-api-issues -> issue 5724 to support this. Star it to give it a higher priority.
I have a feeling that the above issue is blocked by another issue reported there.
From my observations there is no difference between SupportMapFragment and MapFragment when it comes to min zoom level. One thing that matters is device's screen size (or more specifically fragment's size).
From your screenshot I can see zoom level 3. If you want to be able to zoom out to 2, you have to make your fragment a bit smaller. Try adding 50dp margins as a test.
Based on documentation,
The desired zoom level, in the range of 2.0 to 21.0. Values below this range are set to 2.0, and values above it are set to 21.0. Increase the value to zoom in.
Not all areas have tiles at the largest zoom levels.
Googlemap gm;
LatLng cur_Latlng = new LatLng(21.0000, 78.0000);
gm.moveCamera(CameraUpdateFactory.newLatLng(cur_Latlng));
gm.animateCamera(CameraUpdateFactory.zoomTo(10));
gm.getUiSettings().setZoomControlsEnabled(true);
You can increase level from 2.0 to 21.0

Categories

Resources