Skip to content

Map.getMap()

wf9a5m75 edited this page Sep 23, 2014 · 11 revisions

The Map.getMap() is a static method. You can grab a map instance.

###Description The Map.getMap() method returns an instance of the map class. The plugin initializes the native SDK and other thing, it takes a few second. The MAP_READY event is fired when the map is ready to go.

This plugin generates only one map instance using Map.getMap() method. In general, you may want to create multiple maps, but this plugin is not possible.

###Code

var map = plugin.google.maps.Map.getMap();
map.addEventListener(plugin.google.maps.event.MAP_READY, function onMapInit(map) {
  // The map is initialized, then show a map dialog
  map.showDialog();
});

Map.getMap()


Create a map with initialize options

You can intialize the map status with options. This is useful when you want to show the specific location of the map.

const GORYOKAKU_JAPAN = new plugin.google.maps.LatLng(41.796875,140.757007);

var map = plugin.google.maps.Map.getMap({
  'backgroundColor': 'white',
  'mapType': plugin.google.maps.MapTypeId.HYBRID,
  'controls': {
    'compass': true,
    'myLocationButton': true,
    'indoorPicker': true,
    'zoom': true
  },
  'gestures': {
    'scroll': true,
    'tilt': true,
    'rotate': true
  },
  'camera': {
    'latLng': GORYOKAKU_JAPAN,
    'tilt': 30,
    'zoom': 15,
    'bearing': 50
  }
});

img

Join the official community

New versions will be announced through the official community. Stay tune!

Do you have a question or feature request?

Feel free to ask me on the issues tracker.

Or on the official community is also welcome!


New version 2.0-beta2 is available.

The cordova-googlemaps-plugin v2.0 has more faster, more features.

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

Clone this wiki locally