Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ abstract class AbstractGoogleMap(context: Context) : IGoogleMapDelegate.Stub() {
internal var mapLongClickListener: IOnMapLongClickListener? = null
internal var markerClickListener: IOnMarkerClickListener? = null
internal var circleClickListener: IOnCircleClickListener? = null
internal var polygonClickListener : IOnPolygonClickListener? = null
internal var polylineClickListener : IOnPolylineClickListener? = null

internal var myLocationChangeListener: IOnMyLocationChangeListener? = null

Expand Down Expand Up @@ -87,11 +89,11 @@ abstract class AbstractGoogleMap(context: Context) : IGoogleMapDelegate.Stub() {
}

override fun setOnPolygonClickListener(listener: IOnPolygonClickListener?) {
Log.d(TAG, "Not yet implemented: setOnPolygonClickListener")
polygonClickListener = listener
}

override fun setOnPolylineClickListener(listener: IOnPolylineClickListener?) {
Log.d(TAG, "Not yet implemented: setOnPolylineClickListener")
polylineClickListener = listener
}

override fun setOnGroundOverlayClickListener(listener: IOnGroundOverlayClickListener?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG

var lineManager: LineManager? = null
val pendingLines = mutableSetOf<Markup<Line, LineOptions>>()
val lines = mutableMapOf<Long, PolylineImpl>()
var lineId = 0L

var fillManager: FillManager? = null
val pendingFills = mutableSetOf<Markup<Fill, FillOptions>>()
val polygons = mutableMapOf<Long, PolygonImpl>()
val circles = mutableMapOf<Long, CircleImpl>()
var fillId = 0L

Expand Down Expand Up @@ -760,6 +762,9 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
})
fillManager.addClickListener { fill ->
try {
/* IDs are assigned consecutively across all types of fill, so no ID
* corresponds to both circle and polygon.
*/
circles[fill.id]?.let { circle ->
if (circle.isClickable) {
circleClickListener?.let {
Expand All @@ -768,6 +773,29 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
}
}
}
polygons[fill.id]?.let { polygon ->
if (polygon.isClickable) {
polygonClickListener?.let {
it.onPolygonClick(polygon)
return@addClickListener true
}
}
}
} catch (e: Exception) {
Log.w(TAG, e)
}
false
}
lineManager.addClickListener { line ->
try {
lines[line.id]?.let { polyline ->
if (polyline.isClickable) {
polylineClickListener?.let {
it.onPolylineClick(polyline)
return@addClickListener true
}
}
}
} catch (e: Exception) {
Log.w(TAG, e)
}
Expand Down Expand Up @@ -860,8 +888,10 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG
userOnInitializedCallbackList.clear()
lineManager?.onDestroy()
lineManager = null
lines.clear()
fillManager?.onDestroy()
fillManager = null
polygons.clear()
circles.clear()
symbolManager?.onDestroy()
symbolManager = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.google.android.gms.maps.model.PatternItem
import com.google.android.gms.maps.model.PolygonOptions
import com.google.android.gms.maps.model.PolylineOptions
import com.google.android.gms.maps.model.internal.IPolygonDelegate
import com.mapbox.mapboxsdk.plugins.annotation.AnnotationManager
import com.mapbox.mapboxsdk.plugins.annotation.Fill
import com.mapbox.mapboxsdk.plugins.annotation.FillOptions
import com.mapbox.mapboxsdk.utils.ColorUtils
Expand Down Expand Up @@ -226,6 +227,20 @@ class PolygonImpl(private val map: GoogleMapImpl, id: String, options: PolygonOp
strokes.add(PolylineImpl(map, id, options))
}

override fun update(manager: AnnotationManager<*, Fill, FillOptions, *, *, *>) {
synchronized(this) {
val id = annotation?.id
if (removed && id != null) {
map.polygons.remove(id)
}
super.update(manager)
val annotation = annotation
if (annotation != null && id == null) {
map.polygons[annotation.id] = this
}
}
}

override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags) { super.onTransact(code, data, reply, flags) }

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import com.google.android.gms.maps.model.Cap
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.PatternItem
import com.google.android.gms.maps.model.internal.IPolylineDelegate
import com.mapbox.mapboxsdk.plugins.annotation.AnnotationManager
import com.mapbox.mapboxsdk.plugins.annotation.Fill
import com.mapbox.mapboxsdk.plugins.annotation.FillOptions
import com.mapbox.mapboxsdk.plugins.annotation.Line
import com.mapbox.mapboxsdk.plugins.annotation.LineOptions
import com.mapbox.mapboxsdk.utils.ColorUtils
Expand Down Expand Up @@ -169,6 +172,20 @@ class PolylineImpl(private val map: GoogleMapImpl, id: String, options: GmsLineO
map.lineManager?.let { update(it) }
}

override fun update(manager: AnnotationManager<*, Line, LineOptions, *, *, *>) {
synchronized(this) {
val id = annotation?.id
if (removed && id != null) {
map.lines.remove(id)
}
super.update(manager)
val annotation = annotation
if (annotation != null && id == null) {
map.lines[annotation.id] = this
}
}
}

companion object {
private val TAG = "GmsMapPolyline"
}
Expand Down