plugin-googlemaps

Overview

This plugin provides support for Google Maps by utilizing the Google Maps Android SDK.

Getting Started

Set up the development environment

  1. Android Studio is required. If you haven't already done so, download and install it.

  2. Ensure that you are using the Android Gradle plugin version 7.0 or later in Android Studio.

Set up your Google Cloud project for applications with Google Services (Google Maps)

Complete the required Cloud Console setup following the next steps, for more information see:

Set up the project

  1. Add the plugin to the project by following one of the guides:

  1. Configure API key according to the Official Documentation.

  2. In your app's module-level AndroidManifest.xml add the required permissions, for more information see permissions.

    <manifest ...>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application ...>
    ...
    </application>
    </manifest>

Compatibility matrix

Legend of support levels:

Fully supported
Partially supported🟨
Not supported

Map

OmhMap

addMarker
addPolyline
addPolygon
getCameraPositionCoordinate
moveCamera
setZoomGesturesEnabled
setMyLocationEnabled
isMyLocationEnabled
setMyLocationButtonClickListener
setOnCameraMoveStartedListener
setOnCameraIdleListener
setOnMapLoadedCallback
setOnMarkerClickListener🟨
setOnMarkerDragListener
setOnInfoWindowOpenStatusChangeListener🟨
setOnInfoWindowClickListener
setOnInfoWindowLongClickListener
setOnPolylineClickListener
setOnPolygonClickListener
snapshot
setMapStyle
setCustomInfoWindowContentsViewFactory
setCustomInfoWindowViewFactory

Comments for partially supported 🟨 properties:

setOnInfoWindowOpenStatusChangeListener(1) only the onInfoWindowClose event is supported
(2) the listener is invoked before OmhOnMarkerClickListener, in contrast to other providers, which implies that if the window was already open before a click on the marker, the marker click listener would always be invoked after the window is closed
setOnMarkerClickListener(1) the default behaviour of the on click listener (or when a custom handler returns false) is to center the map on the clicked marker
(2) there is a non-overrideable behaviour of the Google Maps plugin, which hides (closes) an open info window when the map is tapped elsewhere

Marker

OmhMarkerOptions

position
title
draggable
anchor
infoWindowAnchor
alpha
snippet
isVisible
isFlat
rotation
backgroundColor🟨
clickable
zIndex

Comments for partially supported 🟨 properties:

backgroundColorhue (H) component of HSV color representation is controllable
alpha channel is unsupported

OmhMarker

getPosition
setPosition
getTitle
setTitle
getClickable
setClickable
getDraggable
setDraggable
setAnchor
setInfoWindowAnchor🟨
getAlpha
setAlpha
getSnippet
setSnippet
setIcon
getIsVisible
setIsVisible
getIsFlat
setIsFlat
getRotation
setRotation
getBackgroundColor
setBackgroundColor🟨
showInfoWindow
hideInfoWindow
getIsInfoWindowShown🟨
remove
getZIndex
setZIndex

Comments for partially supported 🟨 properties:

setInfoWindowAnchoras per this issue, sometimes the info window is anchored to the marker's lat/lng instead of the set anchor - the issue is still open
setBackgroundColoronly hue (H) component of HSV color representation is controllable, alpha channel is unsupported
getIsInfoWindowShowncalling getIsInfoWindowShown() from on click handler will always return false as per this wontfix GoogleMaps issue

Polyline

OmhPolylineOptions

points
clickable
color
width
isVisible
zIndex
jointType
pattern
cap
startCap
endCap
spans

OmhPolyline

getCap
setCap
isClickable
setClickable
getColor
setColor
getEndCap
setEndCap
getJoinType
setJoinType
getPattern
setPattern
getPoints
setPoints
getSpans
setSpans
getStartCap
setStartCap
getTag
setTag
getWidth
setWidth
getZIndex
setZIndex
isVisible
setVisible
remove

Polygon

OmhPolygonOptions

outline
clickable
fillColor
holes
isVisible
strokeColor
strokeJointType
strokePattern
strokeWidth
zIndex

OmhPolygon

getClickable
setClickable
getStrokeColor
setStrokeColor
getFillColor
setFillColor
getStrokeJointType
setStrokeJointType
getStrokePattern
setStrokePattern
getOutline
setOutline
getHoles
setHoles
getTag
setTag
getStrokeWidth
setStrokeWidth
getZIndex
setZIndex
isVisible
setVisible
remove

Documentation

  • /packages//plugin-googlemaps/docs/advanced/README.md

Contributing

Please contribute! We will gladly review any pull requests. Make sure to read the Contributing page first though.

License

Copyright 2023 Open Mobile Hub

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Packages