3.0.6 • Published 14 days ago

@chacabuk/cordova-plugin-googlemaps v3.0.6

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
14 days ago

Cordova GoogleMaps plugin for Android, iOS and Browser v2.8.0

DownloadBuild test (multiple_maps branch)
npm.ionpm.io

This plugin displays Google Maps in your application. This plugin uses these libraries for each platforms:


Guides

Quick install

$> cordova plugin add cordova-plugin-googlemaps

Then set your Google Maps API keys into your config.xml (Android / iOS).

<widget ...>
  <preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="(api key)" />
  <preference name="GOOGLE_MAPS_IOS_API_KEY" value="(api key)" />
</widget>

For browser platform,

// If your app runs this program on browser,
// you need to set `API_KEY_FOR_BROWSER_RELEASE` and `API_KEY_FOR_BROWSER_DEBUG`
// before `plugin.google.maps.Map.getMap()`
//
//   API_KEY_FOR_BROWSER_RELEASE for `https:` protocol
//   API_KEY_FOR_BROWSER_DEBUG for `http:` protocol
//
plugin.google.maps.environment.setEnv({
  'API_KEY_FOR_BROWSER_RELEASE': '(YOUR_API_KEY_IS_HERE)',
  'API_KEY_FOR_BROWSER_DEBUG': ''  // optional
});

// Create a Google Maps native view under the map_canvas div.
var map = plugin.google.maps.Map.getMap(div);

PhoneGap Build settings

<widget ...>

  <!--
    You need to specify cli-7.1.0 or greater version.
    https://build.phonegap.com/current-support
  -->
  <preference name="phonegap-version" value="cli-8.1.1" />
</widget>

Install optional variables (config.xml)

  • npm.io APP_COMPAT_VERSION = (1.1.0) PLAY_SERVICES_BASEMENT_VERSION = (17.2.1) PLAY_SERVICES_BASE_VERSION = (17.2.1) PLAY_SERVICES_GCM_VERSION = (17.0.0) PLAY_SERVICES_LOCATION_VERSION = (17.0.0) GOOGLE_MAPS_ANDROID_SDK = (maps-sdk-3.0.0-beta) cordova-plugin-googlemaps version 2.8.0 or later uses Maps SDK for Android v.3.

  • npm.io LOCATION_WHEN_IN_USE_DESCRIPTION This message is displayed when your application requests LOCATION PERMISSION for only necessary times.

  • npm.io LOCATION_ALWAYS_USAGE_DESCRIPTION This message is displayed when your application requests LOCATION PERMISSION for always.


Please support this plugin activity.

In order to keep this plugin as free, please consider to donate little amount for this project.

Donate


Release Notes

  • v2.8.0

    • Important Change: (Android) If android.useAndroidX=true and android.enableJetifier=true are defined in gradle.properties, this plugin uses Maps SDK for Android v.3.0.0 BETA. If no definition, this plugin uses com.google.android.gms:play-services-maps

    • Add: (Android/iOS/Browser) mapOptions.preferences.restriction which is able to set the camera bounds.

    • Add: (Android/iOS/Browser) mapOptions.preferences.clickableIcons which is able to be disable clicking on POI icons.
    • Bug fix: (Android/iOS/Browser) mapOptions.preferences.building does not work.
    • Add: (Android/iOS/Browser) ElevationService
    • Add: (Android/iOS/Browser) DirectionsService and map.addDirectionsRenderer()
    • Change: (Android/iOS/Browser) map.setDiv(), map.setOptions() returns Promise.
    • Change: (Android/iOS/Browser) Hides __pluginDomId and __pluginMapId properties.

Demos

Demo (Browser)

npm.io


Documentation

npm.io

All documentations are here!!

https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.6.0/README.md

Quick examples


What is the difference between this plugin and Google Maps JavaScript API v3?

Google Maps JavaScript API v3 works on any platforms, but it does not work if device is offline.

This plugin uses three different APIs:

In Android and iOS applications, this plugin displays native Google Maps views, which is faster than Google Maps JavaScript API v3. And it even works if the device is offline.

In Browser platform, this plugin displays JS map views (Google Maps JavaScript API v3). It should work as PWA (progressive web application), but the device has to be online.

In order to work for all platforms, this plugin provides own API instead of each original APIs. You can write your code similar to the Google Maps JavaScript API v3.

Feature comparison table

Google Maps JavaScript API v3Cordova-Plugin-GoogleMaps(Android,iOS)Cordova-Plugin-GoogleMaps(Browser)
Rendering systemJavaScript + HTMLJavaScript + Native API'sJavaScript
Offline mapNot possiblePossible (only your displayed area)Not possible
3D ViewNot possiblePossibleNot possible
PlatformAll browsersAndroid and iOS applications onlyAll browsers
Tile imageBitmapVectorBitmap

Class comparison table

Google Maps JavaScript API v3Cordova-Plugin-GoogleMaps
google.maps.MapMap
google.maps.MarkerMarker
google.maps.InfoWindowDefault InfoWindow, and HtmlInfoWindow
google.maps.CircleCircle
google.maps.RectanglePolygon
google.maps.PolylinePolyline
google.maps.PolygonPolygon
google.maps.GroundOverlayGroundOverlay
google.maps.ImageMapTypeTileOverlay
google.maps.MVCObjectBaseClass
google.maps.MVCArrayBaseArrayClass
google.maps.Geocoderplugin.google.maps.geocoder
google.maps.geometry.sphericalplugin.google.maps.geometry.spherical
google.maps.geometry.encodingplugin.google.maps.geometry.encoding
google.maps.geometry.polyplugin.google.maps.geometry.poly
(not available)MarkerCluster
google.maps.KmlLayerKmlOverlay
(not available)LocationService
google.maps.StreetViewStreetView :sparkles:
google.maps.Data(not available)
google.maps.DirectionsService(not available)
google.maps.DistanceMatrixService(not available)
google.maps.TransitLayer(not available)
google.maps.places.*(not available)
google.maps.visualization.*(not available)

How does this plugin work (Android, iOS)?

This plugin generates native map views, and puts them under the browser.

The map views are not HTML elements. This means that they are not a <div> or anything HTML related. But you can specify the size and position of the map view using its containing <div>.

This plugin changes the background to transparent in your application. Then the plugin detects your touch position, which is either meant for the native map or an html element (which can be on top of your map, or anywhere else on the screen).

npm.io

The benefit of this plugin is the ability to automatically detect which HTML elements are over the map or not.

For instance, in the image below, say you tap on the header div (which is over the map view). The plugin will detect whether your tap is for the header div or for the map view and then pass the touch event appropriately.

This means you can use the native Google Maps views similar to HTML elements.

npm.io


Official Communities

3.0.4

14 days ago

3.0.3

15 days ago

3.0.2

15 days ago

3.0.6

14 days ago

3.0.5

14 days ago

3.0.1

17 days ago

3.0.0

17 days ago