Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TradeMe/MapMe
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Sanson committed Jul 5, 2018
2 parents 9a35ba0 + 0d8bbca commit cf7811b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.iml
/.idea
.gradle
/local.properties
/.idea/workspace.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class GoogleMapMarkerAnnotation(latLng: LatLng,
nativeMarker?.alpha = alpha
}

override fun onUpdateAnchor(anchorUV: Pair<Float, Float>) {
nativeMarker?.setAnchor(anchorUV.first, anchorUV.second)
}

private var nativeMarker: Marker? = null

override fun annotatesObject(objec: Any): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class MapboxMarkerAnnotation(latLng: LatLng,
title: String?,
icon: Bitmap? = null) : MarkerAnnotation(latLng, title, icon) {


override fun onUpdateIcon(icon: Bitmap?) {
nativeMarker?.let {
if (icon != null) {
Expand All @@ -41,6 +40,10 @@ class MapboxMarkerAnnotation(latLng: LatLng,
Log.w(MapboxMarkerAnnotation::class.simpleName, "alpha not supported on MapboxMarkerAnnotations")
}

override fun onUpdateAnchor(anchorUV: Pair<Float, Float>) {
Log.w(MapboxMarkerAnnotation::class.simpleName, "anchor not supported on MapboxMarkerAnnotations")
}

private var nativeMarker: Marker? = null

override fun annotatesObject(objec: Any): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import android.graphics.Bitmap
import nz.co.trademe.mapme.LatLng

abstract class MarkerAnnotation(latLng: LatLng,
title: String? = null,
icon: Bitmap? = null,
zIndex: Float = 0f,
alpha: Float = 1f) : MapAnnotation() {
title: String? = null,
icon: Bitmap? = null,
zIndex: Float = 0f,
alpha: Float = 1f,
anchorUV: Pair<Float, Float> = Pair(0.5f, 1.0f)) : MapAnnotation() {

var latLng: LatLng = latLng
set(value) {
Expand Down Expand Up @@ -39,6 +40,12 @@ abstract class MarkerAnnotation(latLng: LatLng,
onUpdateAlpha(value)
}

var anchor: Pair<Float, Float> = anchorUV
set(value) {
field = value
onUpdateAnchor(value)
}

/**
* Called when an icon has been set on the annotation.
*
Expand Down Expand Up @@ -74,8 +81,16 @@ abstract class MarkerAnnotation(latLng: LatLng,
*/
abstract protected fun onUpdateAlpha(alpha: Float)

/**
* Called when an anchor has been set on the annotation.
*
* Update the native marker with the [anchor]
*/
abstract protected fun onUpdateAnchor(anchorUV: Pair<Float, Float>)


override fun toString(): String {
return "MarkerAnnotation(latLng=$latLng, title=$title, icon=$icon, zIndex=$zIndex, alpha=$alpha)"
return "MarkerAnnotation(latLng=$latLng, title=$title, icon=$icon, zIndex=$zIndex, alpha=$alpha, anchor(U,V)=${anchor.first},${anchor.second})"
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nz.co.trademe.mapme.util

class TestAnnotation : nz.co.trademe.mapme.annotations.MarkerAnnotation(nz.co.trademe.mapme.LatLng(0.0, 0.0), "", null, 0f, 1f) {

class TestAnnotation : nz.co.trademe.mapme.annotations.MarkerAnnotation(nz.co.trademe.mapme.LatLng(0.0, 0.0), "", null, 0f, 1f, Pair(0.5f, 1f)) {
override fun annotatesObject(nativeObject: Any): Boolean {
return false
}
Expand All @@ -27,10 +26,10 @@ class TestAnnotation : nz.co.trademe.mapme.annotations.MarkerAnnotation(nz.co.tr
override fun onUpdateAlpha(alpha: Float) {
}

override fun onUpdateAnchor(anchorUV: Pair<Float, Float>) {
}

override fun toString(): String {
return "TestAnnotation( position = $position)"

}


}

0 comments on commit cf7811b

Please sign in to comment.