Skip to content

Latest commit

 

History

History
58 lines (45 loc) · 1.86 KB

File metadata and controls

58 lines (45 loc) · 1.86 KB

⚠️ This document is aim for older versions (from 2.3.0 to 2.5.3). Document for new version is https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.6.0/README.md

MY_LOCATION_CLICK event

This event is fired when you tap on the location control (blue dot).

Parameters

name type description
location MyLocation current device location

Demo code

<div id="map_canvas"></div>
plugin.google.maps.LocationService.getMyLocation(function(result) {

  // Display the current location map
  var mapDiv = document.getElementById('map_canvas');
  var map = plugin.google.maps.Map.getMap(mapDiv, {
    'camera': {
      'target': result.latLng,
      'zoom': 16
    },
    'controls': {
      'myLocationButton': true,
      'myLocation': true
    }
  });

  map.on(plugin.google.maps.event.MY_LOCATION_CLICK, function(location) {
    var marker = map.addMarker({
      'title': ["Current your location:\n",
          "latitude:" + location.latLng.lat.toFixed(3),
          "longitude:" + location.latLng.lng.toFixed(3),
          "speed:" + location.speed,
          "time:" + location.time,
          "bearing:" + location.bearing].join("\n"),
      'position': location.latLng,
      'animation': plugin.google.maps.Animation.DROP,
      'disableAutoPan': true
    });
    marker.showInfoWindow();
  });

});