This commit is contained in:
metacryst
2026-01-09 11:14:27 -06:00
parent cf03c95664
commit 637c9e4674
2149 changed files with 527743 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@@ -0,0 +1,37 @@
package com.capacitorjs.plugins.googlemaps
import android.content.Context
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.model.MarkerOptions
import com.google.maps.android.clustering.ClusterManager
import com.google.maps.android.clustering.view.DefaultClusterRenderer
class CapacitorClusterManagerRenderer(
context: Context,
map: GoogleMap?,
clusterManager: ClusterManager<CapacitorGoogleMapMarker>?,
minClusterSize: Int?
) : DefaultClusterRenderer<CapacitorGoogleMapMarker>(context, map, clusterManager) {
init {
if(minClusterSize != null && minClusterSize > 0) {
super.setMinClusterSize(minClusterSize)
}
}
override fun onBeforeClusterItemRendered(item: CapacitorGoogleMapMarker, markerOptions: MarkerOptions) {
super.onBeforeClusterItemRendered(item, markerOptions)
item.markerOptions?.let {
markerOptions.position(it.position)
markerOptions.title(it.title)
markerOptions.snippet(it.snippet)
markerOptions.alpha(it.alpha)
markerOptions.flat(it.isFlat)
markerOptions.draggable(it.isDraggable)
if(null != it.icon) {
markerOptions.icon(it.icon)
}
}
}
}

View File

@@ -0,0 +1,93 @@
package com.capacitorjs.plugins.googlemaps
import android.graphics.Color
import android.util.Size
import androidx.core.math.MathUtils
import com.google.android.gms.maps.model.*
import com.google.maps.android.clustering.ClusterItem
import org.json.JSONObject
class CapacitorGoogleMapMarker(fromJSONObject: JSONObject): ClusterItem {
var coordinate: LatLng = LatLng(0.0, 0.0)
var opacity: Float = 1.0f
private var title: String
private var snippet: String
private var zIndex: Float = 0.0f
var isFlat: Boolean = false
var iconUrl: String? = null
var iconSize: Size? = null
var iconAnchor: CapacitorGoogleMapsPoint? = null
var draggable: Boolean = false
var googleMapMarker: Marker? = null
var colorHue: Float? = null
var markerOptions: MarkerOptions? = null
init {
if (!fromJSONObject.has("coordinate")) {
throw InvalidArgumentsError("Marker object is missing the required 'coordinate' property")
}
val latLngObj = fromJSONObject.getJSONObject("coordinate")
if (!latLngObj.has("lat") || !latLngObj.has("lng")) {
throw InvalidArgumentsError("LatLng object is missing the required 'lat' and/or 'lng' property")
}
coordinate = LatLng(latLngObj.getDouble("lat"), latLngObj.getDouble("lng"))
title = fromJSONObject.optString("title")
opacity = fromJSONObject.optDouble("opacity", 1.0).toFloat()
snippet = fromJSONObject.optString("snippet")
isFlat = fromJSONObject.optBoolean("isFlat", false)
iconUrl = fromJSONObject.optString("iconUrl")
if (fromJSONObject.has("iconSize")) {
val iconSizeObject = fromJSONObject.getJSONObject("iconSize")
iconSize = Size(iconSizeObject.optInt("width", 0), iconSizeObject.optInt("height", 0))
}
if (fromJSONObject.has("iconAnchor")) {
val inputAnchorPoint = CapacitorGoogleMapsPoint(fromJSONObject.getJSONObject("iconAnchor"))
iconAnchor = this.buildIconAnchorPoint(inputAnchorPoint)
}
if (fromJSONObject.has("tintColor")) {
val tintColorObject = fromJSONObject.getJSONObject("tintColor")
val r = MathUtils.clamp(tintColorObject.optDouble("r", 0.00), 0.00, 255.0)
val g = MathUtils.clamp(tintColorObject.optDouble("g", 0.00), 0.00, 255.0)
val b = MathUtils.clamp(tintColorObject.optDouble("b", 0.00), 0.00, 255.0)
val hsl = FloatArray(3)
Color.RGBToHSV(r.toInt(), g.toInt(), b.toInt(), hsl)
colorHue = hsl[0]
}
draggable = fromJSONObject.optBoolean("draggable", false)
zIndex = fromJSONObject.optLong("zIndex").toFloat()
}
override fun getPosition(): LatLng {
return LatLng(coordinate.latitude, coordinate.longitude)
}
override fun getTitle(): String {
return title
}
override fun getSnippet(): String {
return snippet
}
override fun getZIndex(): Float {
return zIndex
}
private fun buildIconAnchorPoint(iconAnchor: CapacitorGoogleMapsPoint): CapacitorGoogleMapsPoint? {
iconSize ?: return null
val u: Float = iconAnchor.x / iconSize!!.width
val v: Float = iconAnchor.y / iconSize!!.height
return CapacitorGoogleMapsPoint(u, v)
}
}

View File

@@ -0,0 +1,78 @@
package com.capacitorjs.plugins.googlemaps
import android.graphics.Color
import androidx.core.graphics.toColor
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polyline
import org.json.JSONObject
class CapacitorGoogleMapPolyline(fromJSONObject: JSONObject) {
var path: MutableList<LatLng> = mutableListOf<LatLng>()
var styleSpans: MutableList<CapacitorGoogleMapsStyleSpan> = mutableListOf<CapacitorGoogleMapsStyleSpan>()
var strokeWidth: Float = 1.0f
var strokeColor: Int = Color.BLUE
var clickable: Boolean
var geodesic: Boolean
var zIndex: Float = 0.00f
var tag: String = ""
var googleMapsPolyline: Polyline? = null
init {
if (!fromJSONObject.has("path")) {
throw InvalidArgumentsError("Polyline object is missing the required 'path' property")
}
val pathArray = fromJSONObject.getJSONArray("path")
for (i in 0 until pathArray.length()) {
val obj = pathArray.getJSONObject(i)
if (!obj.has("lat") || !obj.has("lng")) {
throw InvalidArgumentsError("LatLng object is missing the required 'lat' and/or 'lng' property")
}
val lat = obj.getDouble("lat")
val lng = obj.getDouble("lng")
path.add(LatLng(lat, lng))
}
if (fromJSONObject.has("styleSpans")) {
val styleSpanArray = fromJSONObject.getJSONArray("styleSpans")
for (i in 0 until styleSpanArray.length()) {
val obj = styleSpanArray.getJSONObject(i)
if (obj.has("color")) {
val color = obj.getString("color")
if (obj.has("segments")) {
val segments = obj.getDouble("segments")
styleSpans.add(CapacitorGoogleMapsStyleSpan(Color.parseColor(color), segments))
} else {
styleSpans.add(CapacitorGoogleMapsStyleSpan(Color.parseColor(color), null))
}
}
}
}
val strokeOpacity = fromJSONObject.optDouble("strokeOpacity", 1.0)
strokeColor = this.processColor(fromJSONObject.getString("strokeColor"), strokeOpacity)
strokeWidth = fromJSONObject.optDouble("strokeWeight", 1.0).toFloat()
clickable = fromJSONObject.optBoolean("clickable", false)
geodesic = fromJSONObject.optBoolean("geodesic", false)
zIndex = fromJSONObject.optDouble("zIndex", 1.0).toFloat()
tag = fromJSONObject.optString("tag", "")
}
private fun processColor(hex: String, opacity: Double): Int {
val colorInt = Color.parseColor(hex)
val alpha = (opacity * 255.0).toInt()
val red = android.graphics.Color.red(colorInt)
val green = android.graphics.Color.green(colorInt)
val blue = android.graphics.Color.blue(colorInt)
return Color.argb(alpha, red, green, blue)
}
}

View File

@@ -0,0 +1,28 @@
package com.capacitorjs.plugins.googlemaps
import com.google.android.gms.maps.model.TileOverlay
import org.json.JSONObject
class CapacitorGoogleMapTileOverlay(fromJSONObject: JSONObject) {
var url: String
var opacity: Float? = null
var zIndex: Float? = null
var visible: Boolean? = null
var googleMapTileOverlay: TileOverlay? = null
init {
if (!fromJSONObject.has("url")) {
throw InvalidArgumentsError("TileOverlay object is missing the required 'url' property")
}
url = fromJSONObject.getString("url")
if (fromJSONObject.has("opacity")) {
opacity = fromJSONObject.optDouble("opacity").toFloat()
}
if (fromJSONObject.has("visible")) {
visible = fromJSONObject.optBoolean("visible")
}
if (fromJSONObject.has("zIndex")) {
zIndex = fromJSONObject.optLong("zIndex").toFloat()
}
}
}

View File

@@ -0,0 +1,33 @@
package com.capacitorjs.plugins.googlemaps
import org.json.JSONObject
class CapacitorGoogleMapsBounds(fromJSONObject: JSONObject) {
var width: Int = 0
var height: Int = 0
var x: Int = 0
var y: Int = 0
init {
if(!fromJSONObject.has("width")) {
throw InvalidArgumentsError("GoogleMapConfig object is missing the required 'width' property")
}
if(!fromJSONObject.has("height")) {
throw InvalidArgumentsError("GoogleMapConfig object is missing the required 'height' property")
}
if(!fromJSONObject.has("x")) {
throw InvalidArgumentsError("GoogleMapConfig object is missing the required 'x' property")
}
if(!fromJSONObject.has("y")) {
throw InvalidArgumentsError("GoogleMapConfig object is missing the required 'y' property")
}
width = fromJSONObject.getInt("width")
height = fromJSONObject.getInt("height")
x = fromJSONObject.getInt("x")
y = fromJSONObject.getInt("y")
}
}

View File

@@ -0,0 +1,63 @@
package com.capacitorjs.plugins.googlemaps
import android.graphics.Color
import com.google.android.gms.maps.model.Circle
import com.google.android.gms.maps.model.LatLng
import org.json.JSONObject
class CapacitorGoogleMapsCircle(fromJSONObject: JSONObject) {
var center: LatLng
var radius: Float
var strokeWidth: Float = 1.0f
var strokeColor: Int = Color.BLUE
var fillColor: Int = Color.BLUE
var clickable: Boolean
var zIndex: Float = 0.00f
var tag: String = ""
var googleMapsCircle: Circle? = null
init {
if (!fromJSONObject.has("center")) {
throw InvalidArgumentsError("Circle object is missing the required 'center' property")
}
if (!fromJSONObject.has("radius")) {
throw InvalidArgumentsError("Circle object is missing the required 'radius' property")
}
val latLng = fromJSONObject.getJSONObject("center")
if (!latLng.has("lat") || !latLng.has("lng")) {
throw InvalidArgumentsError("LatLng object is missing the required 'lat' and/or 'lng' property")
}
val lat = latLng.getDouble("lat")
val lng = latLng.getDouble("lng")
center = LatLng(lat, lng)
radius = fromJSONObject.getDouble("radius").toFloat()
val strokeOpacity = fromJSONObject.optDouble("strokeOpacity", 1.0)
strokeColor = this.processColor(fromJSONObject.getString("strokeColor"), strokeOpacity)
val fillOpacity = fromJSONObject.optDouble("fillOpacity", 1.0)
fillColor = this.processColor(fromJSONObject.getString("fillColor"), fillOpacity)
strokeWidth = fromJSONObject.optDouble("strokeWeight", 1.0).toFloat()
clickable = fromJSONObject.optBoolean("clickable", false)
zIndex = fromJSONObject.optDouble("zIndex", 1.0).toFloat()
tag = fromJSONObject.optString("tag", "")
}
private fun processColor(hex: String, opacity: Double): Int {
val colorInt = Color.parseColor(hex)
val alpha = (opacity * 255.0).toInt()
val red = android.graphics.Color.red(colorInt)
val green = android.graphics.Color.green(colorInt)
val blue = android.graphics.Color.blue(colorInt)
return Color.argb(alpha, red, green, blue)
}
}

View File

@@ -0,0 +1,23 @@
package com.capacitorjs.plugins.googlemaps
import org.json.JSONObject
class CapacitorGoogleMapsPoint() {
var x: Float = 0.00f
var y: Float = 0.00f
constructor(fromJSONObject: JSONObject) : this() {
if(fromJSONObject.has("x")) {
this.x = fromJSONObject.getDouble("x").toFloat()
}
if(fromJSONObject.has("y")) {
this.y = fromJSONObject.getDouble("y").toFloat()
}
}
constructor(x: Float, y: Float) : this() {
this.x = x;
this.y = y
}
}

View File

@@ -0,0 +1,80 @@
package com.capacitorjs.plugins.googlemaps
import android.graphics.Color
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polygon
import org.json.JSONArray
import org.json.JSONObject
class CapacitorGoogleMapsPolygon(fromJSONObject: JSONObject) {
var shapes: MutableList<MutableList<LatLng>> = mutableListOf<MutableList<LatLng>>()
var strokeWidth: Float = 1.0f
var strokeColor: Int = Color.BLUE
var fillColor: Int = Color.BLUE
var clickable: Boolean
var geodesic: Boolean
var zIndex: Float = 0.00f
var tag: String = ""
var googleMapsPolygon: Polygon? = null
init {
if (!fromJSONObject.has("paths")) {
throw InvalidArgumentsError("Polygon object is missing the required 'paths' property")
}
val pathsArray = fromJSONObject.getJSONArray("paths")
for (i in 0 until pathsArray.length()) {
val arr = pathsArray.optJSONArray(i)
if (arr == null) {
// is a single shape
val shape = this.processShape(pathsArray)
this.shapes.add(shape)
break
} else {
val shape = this.processShape(arr)
this.shapes.add(shape)
}
}
val strokeOpacity = fromJSONObject.optDouble("strokeOpacity", 1.0)
strokeColor = this.processColor(fromJSONObject.getString("strokeColor"), strokeOpacity)
val fillOpacity = fromJSONObject.optDouble("fillOpacity", 1.0)
fillColor = this.processColor(fromJSONObject.getString("fillColor"), fillOpacity)
strokeWidth = fromJSONObject.optDouble("strokeWeight", 1.0).toFloat()
clickable = fromJSONObject.optBoolean("clickable", false)
geodesic = fromJSONObject.optBoolean("geodesic", false)
zIndex = fromJSONObject.optDouble("zIndex", 1.0).toFloat()
tag = fromJSONObject.optString("tag", "")
}
private fun processShape(shapeArr: JSONArray): MutableList<LatLng> {
var shape = mutableListOf<LatLng>()
for (i in 0 until shapeArr.length()) {
val obj = shapeArr.getJSONObject(i)
if (!obj.has("lat") || !obj.has("lng")) {
throw InvalidArgumentsError("LatLng object is missing the required 'lat' and/or 'lng' property")
}
val lat = obj.getDouble("lat")
val lng = obj.getDouble("lng")
shape.add(LatLng(lat, lng))
}
return shape
}
private fun processColor(hex: String, opacity: Double): Int {
val colorInt = Color.parseColor(hex)
val alpha = (opacity * 255.0).toInt()
val red = android.graphics.Color.red(colorInt)
val green = android.graphics.Color.green(colorInt)
val blue = android.graphics.Color.blue(colorInt)
return Color.argb(alpha, red, green, blue)
}
}

View File

@@ -0,0 +1,5 @@
package com.capacitorjs.plugins.googlemaps
import android.graphics.Color
data class CapacitorGoogleMapsStyleSpan(val color: Int, val segments: Double?)

View File

@@ -0,0 +1,50 @@
package com.capacitorjs.plugins.googlemaps
import com.google.android.gms.maps.model.LatLng
import org.json.JSONObject
class GoogleMapCameraConfig(fromJSONObject: JSONObject) {
var coordinate: LatLng? = null
var zoom: Double? = null
var angle: Double? = null
var bearing: Double? = null
var animate: Boolean? = null
var animationDuration: Double? = null
init {
if (fromJSONObject.has("zoom")) {
zoom = fromJSONObject.getDouble("zoom")
}
if(fromJSONObject.has("angle")) {
angle = fromJSONObject.getDouble("angle")
}
if (fromJSONObject.has("bearing")) {
bearing = fromJSONObject.getDouble("bearing")
}
if (fromJSONObject.has("animate")) {
animate = fromJSONObject.getBoolean("animate")
}
if (fromJSONObject.has("animationDuration")) {
animationDuration = fromJSONObject.getDouble("animationDuration")
}
if (fromJSONObject.has("coordinate")) {
val coordinateJSONObject = fromJSONObject.getJSONObject("coordinate")
if(!coordinateJSONObject.has("lat") || !coordinateJSONObject.has("lng")) {
throw InvalidArgumentsError("LatLng object is missing the required 'lat' and/or 'lng' property")
}
val lat = coordinateJSONObject.getDouble("lat")
val lng = coordinateJSONObject.getDouble("lng")
coordinate = LatLng(lat, lng)
} else {
coordinate = null
}
}
}

View File

@@ -0,0 +1,165 @@
package com.capacitorjs.plugins.googlemaps
import com.google.android.gms.maps.GoogleMapOptions
import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.LatLngBounds
import org.json.JSONObject
class GoogleMapConfig(fromJSONObject: JSONObject) {
var width: Int = 0
var height: Int = 0
var x: Int = 0
var y: Int = 0
var center: LatLng = LatLng(0.0, 0.0)
var googleMapOptions: GoogleMapOptions? = null
var zoom: Int = 0
var liteMode: Boolean = false
var devicePixelRatio: Float = 1.00f
var styles: String? = null
var mapId: String? = null
var minZoom: Int? = null
var maxZoom: Int? = null
var mapTypeId: String? = null
var restriction: GoogleMapConfigRestriction? = null
var heading: Double? = null
init {
if (!fromJSONObject.has("width")) {
throw InvalidArgumentsError(
"GoogleMapConfig object is missing the required 'width' property"
)
}
if (!fromJSONObject.has("height")) {
throw InvalidArgumentsError(
"GoogleMapConfig object is missing the required 'height' property"
)
}
if (!fromJSONObject.has("x")) {
throw InvalidArgumentsError(
"GoogleMapConfig object is missing the required 'x' property"
)
}
if (!fromJSONObject.has("y")) {
throw InvalidArgumentsError(
"GoogleMapConfig object is missing the required 'y' property"
)
}
if (!fromJSONObject.has("zoom")) {
throw InvalidArgumentsError(
"GoogleMapConfig object is missing the required 'zoom' property"
)
}
if (fromJSONObject.has("devicePixelRatio")) {
devicePixelRatio = fromJSONObject.getDouble("devicePixelRatio").toFloat()
}
if (!fromJSONObject.has("center")) {
throw InvalidArgumentsError(
"GoogleMapConfig object is missing the required 'center' property"
)
}
val centerJSONObject = fromJSONObject.getJSONObject("center")
if (!centerJSONObject.has("lat") || !centerJSONObject.has("lng")) {
throw InvalidArgumentsError(
"LatLng object is missing the required 'lat' and/or 'lng' property"
)
}
liteMode =
fromJSONObject.has("androidLiteMode") &&
fromJSONObject.getBoolean("androidLiteMode")
width = fromJSONObject.getInt("width")
height = fromJSONObject.getInt("height")
x = fromJSONObject.getInt("x")
y = fromJSONObject.getInt("y")
val tempZoom = fromJSONObject.getInt("zoom")
var tempMinZoom = fromJSONObject.optInt("minZoom").takeIf { fromJSONObject.has("minZoom") }
var tempMaxZoom = fromJSONObject.optInt("maxZoom").takeIf { fromJSONObject.has("maxZoom") }
if (tempMinZoom != null && tempMaxZoom != null && tempMinZoom > tempMaxZoom) {
tempMinZoom = tempMaxZoom.also { tempMaxZoom = tempMinZoom }
}
minZoom = tempMinZoom
maxZoom = tempMaxZoom
zoom = tempZoom.coerceIn(
tempMinZoom ?: Int.MIN_VALUE,
tempMaxZoom ?: Int.MAX_VALUE
)
mapTypeId = fromJSONObject.optString("mapTypeId").takeIf { fromJSONObject.has("mapTypeId") }
val lat = centerJSONObject.getDouble("lat")
val lng = centerJSONObject.getDouble("lng")
center = LatLng(lat, lng)
val cameraPosition = CameraPosition(center, zoom.toFloat(), 0.0F, 0.0F)
styles = fromJSONObject.getString("styles")
mapId = fromJSONObject.getString("androidMapId")
restriction = fromJSONObject.optJSONObject("restriction")?.let { GoogleMapConfigRestriction(it) }
heading = fromJSONObject.optDouble("heading").takeIf { fromJSONObject.has("heading") }
googleMapOptions = GoogleMapOptions().camera(cameraPosition).liteMode(liteMode)
if (mapId != null) {
googleMapOptions?.mapId(mapId!!)
}
}
}
class GoogleMapConfigRestriction(fromJSONObject: JSONObject) {
var latLngBounds: LatLngBounds
init {
if (!fromJSONObject.has("latLngBounds")) {
throw InvalidArgumentsError(
"GoogleMapConfigRestriction object is missing the required 'latLngBounds' property"
)
}
val latLngBoundsObj = fromJSONObject.getJSONObject("latLngBounds")
if (!latLngBoundsObj.has("north")) {
throw InvalidArgumentsError(
"GoogleMapConfigRestriction object is missing the required 'latLngBounds.north' property"
)
}
if (!latLngBoundsObj.has("south")) {
throw InvalidArgumentsError(
"GoogleMapConfigRestriction object is missing the required 'latLngBounds.south' property"
)
}
if (!latLngBoundsObj.has("east")) {
throw InvalidArgumentsError(
"GoogleMapConfigRestriction object is missing the required 'latLngBounds.east' property"
)
}
if (!latLngBoundsObj.has("west")) {
throw InvalidArgumentsError(
"GoogleMapConfigRestriction object is missing the required 'latLngBounds.west' property"
)
}
val north = latLngBoundsObj.getDouble("north")
val south = latLngBoundsObj.getDouble("south")
val east = latLngBoundsObj.getDouble("east")
val west = latLngBoundsObj.getDouble("west")
latLngBounds = LatLngBounds(
LatLng(south, west),
LatLng(north, east)
)
}
}

View File

@@ -0,0 +1,114 @@
package com.capacitorjs.plugins.googlemaps
import org.json.JSONObject
import kotlin.Exception
enum class GoogleMapErrors {
UNHANDLED_ERROR, INVALID_MAP_ID, MAP_NOT_FOUND, MARKER_NOT_FOUND, INVALID_ARGUMENTS, PERMISSIONS_DENIED_LOCATION, GOOGLE_MAP_NOT_AVAILABLE, BOUNDS_NOT_FOUND, TILE_OVERLAY_NOT_FOUND
}
class GoogleMapErrorObject(val code: Int, val message: String, val extra: HashMap<String,Any> = HashMap()) {
private fun asJSONObject(): JSONObject {
val returnJSONObject = JSONObject()
returnJSONObject.put("code", code)
returnJSONObject.put("message", message)
returnJSONObject.put("extra", extra)
return returnJSONObject
}
override fun toString(): String {
return this.asJSONObject().toString()
}
}
fun getErrorObject(err: GoogleMapsError): GoogleMapErrorObject {
return when(err) {
is InvalidArgumentsError -> {
GoogleMapErrorObject(err.getErrorCode(), "Invalid Arguments Provided: ${err.message}.")
}
is InvalidMapIdError -> {
GoogleMapErrorObject(err.getErrorCode(), "Missing or invalid map id.")
}
is MapNotFoundError -> {
GoogleMapErrorObject(err.getErrorCode(), "Map not found for provided id.")
}
is MarkerNotFoundError -> {
GoogleMapErrorObject(err.getErrorCode(), "Marker not found for provided id.")
}
is PermissionDeniedLocation -> {
GoogleMapErrorObject(err.getErrorCode(), "Permissions denied for accessing device location.")
}
is GoogleMapNotAvailable -> {
GoogleMapErrorObject(err.getErrorCode(), "Google Map is not available.")
}
is BoundsNotFoundError -> {
GoogleMapErrorObject(err.getErrorCode(), "Google Map Bounds could not be found.")
}
is TileOverlayNotFoundError -> {
GoogleMapErrorObject(err.getErrorCode(), "Tile overlay not found for provided id.")
}
else -> {
GoogleMapErrorObject(err.getErrorCode(), "Unhandled Error: ${err.message}.")
}
}
}
fun getErrorObject(err: Exception): GoogleMapErrorObject {
return GoogleMapErrorObject(0, "Unhandled Error: ${err.message}.")
}
open class GoogleMapsError(message: String? = ""): Throwable(message) {
open fun getErrorCode(): Int {
return GoogleMapErrors.UNHANDLED_ERROR.ordinal
}
}
class InvalidMapIdError(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.INVALID_MAP_ID.ordinal
}
}
class MapNotFoundError(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.MAP_NOT_FOUND.ordinal
}
}
class MarkerNotFoundError(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.MARKER_NOT_FOUND.ordinal
}
}
class TileOverlayNotFoundError(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.TILE_OVERLAY_NOT_FOUND.ordinal
}
}
class InvalidArgumentsError(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.INVALID_ARGUMENTS.ordinal
}
}
class PermissionDeniedLocation(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.PERMISSIONS_DENIED_LOCATION.ordinal
}
}
class GoogleMapNotAvailable(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.GOOGLE_MAP_NOT_AVAILABLE.ordinal
}
}
class BoundsNotFoundError(message: String? = ""): GoogleMapsError(message) {
override fun getErrorCode(): Int {
return GoogleMapErrors.BOUNDS_NOT_FOUND.ordinal
}
}

View File

@@ -0,0 +1,28 @@
package com.capacitorjs.plugins.googlemaps
import org.json.JSONObject
class GoogleMapPadding(fromJSONObject: JSONObject) {
var top: Int = 0
var bottom: Int = 0
var left: Int = 0
var right: Int = 0
init {
if(fromJSONObject.has("top")) {
top = fromJSONObject.getInt("top")
}
if(fromJSONObject.has("bottom")) {
bottom = fromJSONObject.getInt("bottom")
}
if(fromJSONObject.has("left")) {
left = fromJSONObject.getInt("left")
}
if(fromJSONObject.has("right")) {
right = fromJSONObject.getInt("right")
}
}
}

View File