I'm using version 1.3.1 of the Google Maps Extension and am trying to exclude a marker from being clustered. I have one marker that is set in the onCreate method of my app and it represents My Location. I want this to always be visible and not be clustered like the rest of my markers. Is this possible? I tried adding the marker before I set the clustering settings and before I called setClustering on the GoogleMaps object, but it doesn't seem to work.
If you are using just one Marker which should not be clustered with all other, you can see a workaround in comment #2 here:
https://code.google.com/p/android-maps-extensions/issues/detail?id=10#c2
Basically using SupportMapFragment.getMap().addMarker(...) instead of SupportMapFragment.getExtendedMap()
The problem is you will get null in GoogleMap callbacks like onMarkerClick, but for just one Marker you can find out it's "the Marker". Clustering engine will not be aware of Marker added that way.
You will also have class name collision, so you have to use full class name for original library like com.google.android.gms.maps.model.Marker in case you keep a reference to this Marker.
Hope it helps until this improvement is implemented.
Edit:
This is available as of version 1.5 via simple call:
theMarker.setClusterGroup(777);
The default group is 0 and only Markers with the same group are clustered together, so if you change one Marker's group, you'll get the desired effect.
Related
I've built my app layout and it's all looking good to me about where my things will go. I'll put a screenshot of the one fragment in which I want to place a small google map API.
I want the google map in the button which says "MAP". I'm fairly new to android development and would really appreciate it if someone could help me out with this and/or send me links to the videos that talk about exactly what I want because everything that I've tried searching for is either not necessary or not what I want.
Here's my page;
I want to add a map to the 'MAP' button that is clickable and will take me to google maps or if that's not considered 'API', I want it to become full screen. I'd prefer if it takes me to google maps though.
Thanks a lot for the help!
The basic steps for adding a map are:
You need to set up your API key and Gradle dependencies.
https://developers.google.com/maps/documentation/android-sdk/config
Add a Fragment object to the Activity that will handle the map. The easiest way to do this is to add a element to the layout file for the Activity.
Implement the OnMapReadyCallback interface and use the onMapReady(GoogleMap) callback method to get a handle to the GoogleMap object. The GoogleMap object is the internal representation of the map itself. To set the view options for a map, you modify its GoogleMap object.
Call getMapAsync() on the fragment to register the callback.
Please go through this link to get you started: https://developers.google.com/maps/documentation/android-sdk/map
My app shows a user marker. Basically, the user marker shows where the current user is on the map but I also have other markers placed on the map. In the end, it covers up my user marker. I want my User Marker to be on the top of the map. I want it to be rendered last so it shows on the very top.
Any idea?
In case anyone is looking for a newer answer for latest SDKs.
Mapbox Marker class is now deprecated in newer versions of Mapbox Android SDK. Annotations plugin is suggested instead, which has a Symbol class for markers.
In mapbox-android-plugin-annotation-v7 library Symbol class had a withZIndex() method which allowed to manipulate Z-ordering of map objects.
In mapbox-android-plugin-annotation-v8 this method was renamed to withSymbolSortKey() (which was a bit tricky to find and discover).
There is a solution from here https://github.com/mapbox/mapbox-gl-native/pull/5294
If you use MarkerView, you can bring your marker to the very top with MarkerViewManager#select call.
mapboxMap.getMarkerViewManager().select(marker);
It will end by calling View#bringToFront from Android View API, the selected marker view will show on top of all other marker views.
I think this may help:
Mapbox Android SDK: Bring marker to front
Yes. Starting with Mapbox Android SDK v4.1, the selected marker will
come to front.
You can select a marker with mapboxMap.selectMarker(marker);
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.
In my ExpandableListView I need to add Google Map on each item.
I tried with putting Map on each item but its giving me inflate exception. And its is also stated that an MapActivity can contain only one MapView.
Is there any other idea to achieve this.
For refrence you can see here.
Your comments regarding MapActivity indicate that you are using Maps V1, which is deprecated. Maps V2 does not require a MapActivity and can have multiple maps.
That being said, your proposed implementation is unlikely to work well, as putting scrollable things in scrollable things can be problematic. It also is rather unrealisitc IMHO -- whoever came up with that design has never used an actual smartphone, as there's no point in having an interactive map that small (again, IMHO).
Consider using static maps (there's a Google API for that somewhere) for inside the ExpandableListView, where a tap on the map brings up the full map, either in your app or in the standard Maps app.
I recommend to not use static map (as for example it's not possible to zoom to particular bounds with newLatLngBounds or add a circle in particular lat/lon).
I recommend to use map fragment in lite mode:
In addition, there is also a new ‘lite mode’ map option, ideal for situations where you want to provide a number of smaller maps, or a map that is so small that meaningful interaction is impractical, such as a thumbnail in a list. A lite mode map is a bitmap image of a map at a specified location and zoom level.
Map fragment can be nested in the list.
I have the map working on android and am able to populate it with overlays.
But the overlay ability is only so good. If I add too many overlays and refresh too often, I can create an app that is very processor-hard (useless).
What I want to do is only load the overlays that are within the zoom level of the map.
How to I get at what level the map is zoomed using Google APIS, overlays, itemized, and geopoints?
Thanks,
You can use the getZoomLevel and getMapCenter methods on MapView. You might also read through the MapView class documentation.
You can directly get that from class without any method.
map.getCameraPosition().zoom