diff options
author | Brad Leege <bleege@gmail.com> | 2016-06-06 16:14:39 -0500 |
---|---|---|
committer | Brad Leege <bleege@gmail.com> | 2016-06-07 15:04:11 -0500 |
commit | 61a5bea043e35e21a5d8eebf762d16bb9971fa0a (patch) | |
tree | 9adc27ee8aa18f532db2697b90f96ac83b5b6aed /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox | |
parent | b711979e328c54dbfd3240ea339a1662c7f9c808 (diff) | |
download | qtlocation-mapboxgl-61a5bea043e35e21a5d8eebf762d16bb9971fa0a.tar.gz |
[android] #5237 - Enabled Updates To InfoWindow's Title and Snippet
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox')
2 files changed, 38 insertions, 3 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java index 36d56591c8..3c4868c84b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java @@ -23,6 +23,7 @@ public abstract class Annotation implements Comparable<Annotation> { */ private long id = -1; // -1 unless added to a MapView protected MapboxMap mapboxMap; + protected MapView mapView; protected Annotation() { } @@ -68,6 +69,22 @@ public abstract class Annotation implements Comparable<Annotation> { return mapboxMap; } + /** + * Don not use this method. Used internally by the SDK. + */ + public void setMapView(MapView mapView) { + this.mapView = mapView; + } + + /** + * Gets the associated MapView + * + * @return The MapView + */ + protected MapView getMapView() { + return mapView; + } + @Override public int compareTo(@NonNull Annotation annotation) { if (id < annotation.getId()) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java index 16b219684f..2d4ec4257e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java @@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.annotations; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; - import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; @@ -91,8 +90,9 @@ public class Marker extends Annotation { } } - void setSnippet(String snippet) { + public void setSnippet(String snippet) { this.snippet = snippet; + refreshInfoWindowContent(); } /** @@ -112,8 +112,25 @@ public class Marker extends Annotation { return icon; } - void setTitle(String title) { + public void setTitle(String title) { this.title = title; + refreshInfoWindowContent(); + } + + /** + * Update only for default Marker's InfoWindow content for Title and Snippet + */ + private void refreshInfoWindowContent() { + if (isInfoWindowShown() && mapView != null && mapboxMap != null && mapboxMap.getInfoWindowAdapter() == null) { + InfoWindow infoWindow = getInfoWindow(mapView); + if (mapView.getContext() != null) { + infoWindow.adaptDefaultMarker(this, mapboxMap, mapView); + } + MapboxMap map = getMapboxMap(); + if (map != null) { + map.updateMarker(this); + } + } } /** @@ -121,6 +138,7 @@ public class Marker extends Annotation { */ public InfoWindow showInfoWindow(@NonNull MapboxMap mapboxMap, @NonNull MapView mapView) { setMapboxMap(mapboxMap); + setMapView(mapView); MapboxMap.InfoWindowAdapter infoWindowAdapter = getMapboxMap().getInfoWindowAdapter(); if (infoWindowAdapter != null) { // end developer is using a custom InfoWindowAdapter |