@ionic-native/google-maps
Version:
Ionic Native - Native plugins for ionic apps
1,060 lines • 313 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var _this = this;
import { IonicNativePlugin, instanceAvailability, cordovaInstance, instancePropertyGet, instancePropertySet, checkAvailability, getPromise } from '@ionic-native/core';
import { Observable } from 'rxjs';
var TARGET_ELEMENT_FINDING_QUERYS = [
'.show-page #',
'ion-router-outlet[main] #',
'#'
];
var LatLng = /** @class */ (function () {
function LatLng(lat, lng) {
this.lat = lat;
this.lng = lng;
}
LatLng.prototype.equals = function (other) {
return this.lat === other.lat && this.lng === other.lng;
};
LatLng.prototype.toString = function () {
return this.lat + ',' + this.lng;
};
LatLng.prototype.toUrlValue = function (precision) {
precision = precision || 6;
return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision);
};
return LatLng;
}());
export { LatLng };
var LatLngBounds = /** @class */ (function () {
function LatLngBounds(points) {
this._objectInstance = new (GoogleMaps.getPlugin()).LatLngBounds(points);
}
LatLngBounds.prototype.toString = function () { return cordovaInstance(this, "toString", { "sync": true }, arguments); };
LatLngBounds.prototype.toUrlValue = function (precision) { return cordovaInstance(this, "toUrlValue", { "sync": true }, arguments); };
LatLngBounds.prototype.extend = function (LatLng) { return cordovaInstance(this, "extend", { "sync": true }, arguments); };
LatLngBounds.prototype.contains = function (LatLng) { return cordovaInstance(this, "contains", { "sync": true }, arguments); };
LatLngBounds.prototype.getCenter = function () { return cordovaInstance(this, "getCenter", { "sync": true }, arguments); };
Object.defineProperty(LatLngBounds.prototype, "northeast", {
get: function () { return instancePropertyGet(this, "northeast"); },
set: function (value) { instancePropertySet(this, "northeast", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(LatLngBounds.prototype, "southwest", {
get: function () { return instancePropertyGet(this, "southwest"); },
set: function (value) { instancePropertySet(this, "southwest", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(LatLngBounds.prototype, "type", {
get: function () { return instancePropertyGet(this, "type"); },
set: function (value) { instancePropertySet(this, "type", value); },
enumerable: true,
configurable: true
});
return LatLngBounds;
}());
export { LatLngBounds };
var VisibleRegion = /** @class */ (function () {
function VisibleRegion(southwest, northeast, farLeft, farRight, nearLeft, nearRight) {
this._objectInstance = new (GoogleMaps.getPlugin()).VisibleRegion(southwest, northeast, farLeft, farRight, nearLeft, nearRight);
}
VisibleRegion.prototype.toString = function () { return cordovaInstance(this, "toString", { "sync": true }, arguments); };
VisibleRegion.prototype.toUrlValue = function (precision) { return cordovaInstance(this, "toUrlValue", { "sync": true }, arguments); };
VisibleRegion.prototype.contains = function (LatLng) { return cordovaInstance(this, "contains", { "sync": true }, arguments); };
Object.defineProperty(VisibleRegion.prototype, "northeast", {
get: function () { return instancePropertyGet(this, "northeast"); },
set: function (value) { instancePropertySet(this, "northeast", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(VisibleRegion.prototype, "southwest", {
get: function () { return instancePropertyGet(this, "southwest"); },
set: function (value) { instancePropertySet(this, "southwest", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(VisibleRegion.prototype, "farLeft", {
get: function () { return instancePropertyGet(this, "farLeft"); },
set: function (value) { instancePropertySet(this, "farLeft", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(VisibleRegion.prototype, "farRight", {
get: function () { return instancePropertyGet(this, "farRight"); },
set: function (value) { instancePropertySet(this, "farRight", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(VisibleRegion.prototype, "nearLeft", {
get: function () { return instancePropertyGet(this, "nearLeft"); },
set: function (value) { instancePropertySet(this, "nearLeft", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(VisibleRegion.prototype, "nearRight", {
get: function () { return instancePropertyGet(this, "nearRight"); },
set: function (value) { instancePropertySet(this, "nearRight", value); },
enumerable: true,
configurable: true
});
Object.defineProperty(VisibleRegion.prototype, "type", {
get: function () { return instancePropertyGet(this, "type"); },
set: function (value) { instancePropertySet(this, "type", value); },
enumerable: true,
configurable: true
});
return VisibleRegion;
}());
export { VisibleRegion };
/**
* @hidden
*/
export var StreetViewSource = {
DEFAULT: 'DEFAULT',
OUTDOOR: 'OUTDOOR'
};
/**
* @hidden
* You can listen to these events where appropriate
*/
export var GoogleMapsEvent = {
MAP_READY: 'map_ready',
MAP_CLICK: 'map_click',
MAP_LONG_CLICK: 'map_long_click',
POI_CLICK: 'poi_click',
MY_LOCATION_CLICK: 'my_location_click',
MY_LOCATION_BUTTON_CLICK: 'my_location_button_click',
INDOOR_BUILDING_FOCUSED: 'indoor_building_focused',
INDOOR_LEVEL_ACTIVATED: 'indoor_level_activated',
CAMERA_MOVE_START: 'camera_move_start',
CAMERA_MOVE: 'camera_move',
CAMERA_MOVE_END: 'camera_move_end',
OVERLAY_CLICK: 'overlay_click',
POLYGON_CLICK: 'polygon_click',
POLYLINE_CLICK: 'polyline_click',
CIRCLE_CLICK: 'circle_click',
GROUND_OVERLAY_CLICK: 'groundoverlay_click',
INFO_CLICK: 'info_click',
INFO_LONG_CLICK: 'info_long_click',
INFO_CLOSE: 'info_close',
INFO_OPEN: 'info_open',
MARKER_CLICK: 'marker_click',
MARKER_DRAG: 'marker_drag',
MARKER_DRAG_START: 'marker_drag_start',
MARKER_DRAG_END: 'marker_drag_end',
MAP_DRAG: 'map_drag',
MAP_DRAG_START: 'map_drag_start',
MAP_DRAG_END: 'map_drag_end',
KML_CLICK: 'kml_click',
PANORAMA_READY: 'panorama_ready',
PANORAMA_CAMERA_CHANGE: 'panorama_camera_change',
PANORAMA_LOCATION_CHANGE: 'panorama_location_change',
PANORAMA_CLICK: 'panorama_click'
};
/**
* @hidden
*/
export var GoogleMapsAnimation = {
BOUNCE: 'BOUNCE',
DROP: 'DROP'
};
/**
* @hidden
*/
export var GoogleMapsMapTypeId = {
NORMAL: 'MAP_TYPE_NORMAL',
ROADMAP: 'MAP_TYPE_NORMAL',
SATELLITE: 'MAP_TYPE_SATELLITE',
HYBRID: 'MAP_TYPE_HYBRID',
TERRAIN: 'MAP_TYPE_TERRAIN',
NONE: 'MAP_TYPE_NONE'
};
var GoogleMaps = /** @class */ (function (_super) {
__extends(GoogleMaps, _super);
function GoogleMaps() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Creates a new GoogleMap instance
* @param element {string | HTMLElement} Element ID or reference to attach the map to
* @param options {GoogleMapOptions} [options] Options
* @return {GoogleMap}
*/
GoogleMaps.create = function (element, options) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
if (element instanceof HTMLElement) {
if (!element.offsetParent) {
throw new Error('Element must be under <body>');
}
if (element.getAttribute('__pluginMapId')) {
throw new Error(element.tagName + "[__pluginMapId='" + element.getAttribute('__pluginMapId') + "'] has already map.");
}
}
else if (typeof element === 'object') {
options = element;
element = null;
}
var googleMap = new GoogleMap(element, options);
googleMap.set('_overlays', {});
return googleMap;
}
else {
var errorMessage = [
'[GoogleMaps]'
];
if (!window.cordova) {
errorMessage.push('You need to execute "$> ionic cordova run browser".');
errorMessage.push('"$> ionic serve" is not supported.');
}
else {
errorMessage.push('cordova-plugin-googlemaps is not installed or not ready yet.');
}
if (element instanceof HTMLElement) {
displayErrorMessage(element, errorMessage.join('<br />'));
}
else if (typeof element === 'string') {
var targets = Array.from(document.querySelectorAll('#' + element));
if (targets.length > 0) {
targets = targets.filter(function (target) {
return !target.hasAttribute('__pluginmapid');
});
}
if (targets.length === 1 && targets[0]) {
displayErrorMessage(targets[0], errorMessage.join('<br />'));
}
}
throw new Error(errorMessage.join(''));
}
};
/**
* @deprecation keep this for backward compatibility.
* @hidden
*/
GoogleMaps.prototype.create = function (element, options) {
console.error('GoogleMaps', '[deprecated] Please use GoogleMaps.create()');
return GoogleMaps.create(element, options);
};
/**
* Creates a new StreetView instance
* @param element {string | HTMLElement} Element ID or reference to attach the map to
* @param options {StreetViewOptions} [options] Options
* @return {StreetViewPanorama}
*/
GoogleMaps.createPanorama = function (element, options) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
if (element instanceof HTMLElement) {
if (!element.offsetParent) {
throw new Error('Element must be under <body>');
}
if (element.getAttribute('__pluginMapId')) {
throw new Error(element.tagName + "[__pluginMapId='" + element.getAttribute('__pluginMapId') + "'] has already map.");
}
}
return new StreetViewPanorama(element, options);
}
else {
var errorMessage = [
'[GoogleMaps]'
];
if (!window.cordova) {
errorMessage.push('You need to execute "$> ionic cordova run browser".');
errorMessage.push('"$> ionic serve" is not supported.');
}
else {
errorMessage.push('cordova-plugin-googlemaps is not installed or not ready yet.');
}
if (element instanceof HTMLElement) {
displayErrorMessage(element, errorMessage.join('<br />'));
}
else if (typeof element === 'string') {
var targets = Array.from(document.querySelectorAll('#' + element));
if (targets.length > 0) {
targets = targets.filter(function (target) {
return !target.hasAttribute('__pluginmapid');
});
}
if (targets.length === 1 && targets[0]) {
displayErrorMessage(targets[0], errorMessage.join('<br />'));
}
}
throw new Error(errorMessage.join(''));
}
};
GoogleMaps.pluginName = "GoogleMaps";
GoogleMaps.pluginRef = "plugin.google.maps";
GoogleMaps.plugin = "cordova-plugin-googlemaps";
GoogleMaps.repo = "https://github.com/mapsplugin/cordova-plugin-googlemaps";
GoogleMaps.document = "https://ionicframework.com/docs/native/google-maps/";
GoogleMaps.install = "ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID=\"YOUR_ANDROID_API_KEY_IS_HERE\" --variable API_KEY_FOR_IOS=\"YOUR_IOS_API_KEY_IS_HERE\"";
GoogleMaps.installVariables = ["API_KEY_FOR_ANDROID", "API_KEY_FOR_IOS"];
GoogleMaps.platforms = ["Android", "iOS", "Browser"];
return GoogleMaps;
}(IonicNativePlugin));
export { GoogleMaps };
var displayErrorMessage = function (element, message) {
var errorDiv = document.createElement('div');
errorDiv.innerHTML = message;
errorDiv.style.color = 'red';
errorDiv.style.position = 'absolute';
errorDiv.style.width = '80%';
errorDiv.style.height = '50%';
errorDiv.style.top = '0px';
errorDiv.style.bottom = '0px';
errorDiv.style.right = '0px';
errorDiv.style.left = '0px';
errorDiv.style.padding = '0px';
errorDiv.style.margin = 'auto';
element.style.position = 'relative';
element.style.backgroundColor = '#ccc7';
element.appendChild(errorDiv);
};
var normalizeArgumentsOfEventListener = function (_objectInstance, args) {
if (args[args.length - 1] instanceof GoogleMaps.getPlugin().BaseClass) {
if (args[args.length - 1].type === 'Map' || args[args.length - 1].type === 'StreetViewPanorama') {
args[args.length - 1] = _this;
}
else if (_objectInstance.__pgmId.indexOf('markercluster_') !== -1) {
var _overlays = _objectInstance.getMap().get('_overlays') || {};
var overlay = _overlays[args[args.length - 1].getId()];
if (!overlay) {
var markerJS = args[args.length - 1];
var markerId_1 = markerJS.getId();
var markerCluster = _objectInstance;
overlay = new Marker(markerCluster.getMap(), markerJS);
_objectInstance.getMap().get('_overlays')[markerId_1] = overlay;
markerJS.one(markerJS.getId() + '_remove', function () {
_objectInstance.getMap().get('_overlays')[markerId_1] = null;
delete _objectInstance.getMap().get('_overlays')[markerId_1];
});
}
args[args.length - 1] = overlay;
}
else {
args[args.length - 1] = _objectInstance.getMap().get('_overlays')[args[args.length - 1].getId()];
}
}
return args;
};
var BaseClass = /** @class */ (function () {
function BaseClass(objInstance) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
if (!objInstance) {
objInstance = new (GoogleMaps.getPlugin().BaseClass)();
}
this._objectInstance = objInstance;
}
else {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before executing any methods.');
}
}
BaseClass.prototype.addEventListener = function (eventName) {
var _this = this;
return (function () {
if (instanceAvailability(_this) === true) {
return new Observable(function (observer) {
_this._objectInstance.addEventListener(eventName, function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var newArgs = normalizeArgumentsOfEventListener.call(_this, _this._objectInstance, args);
observer.next(newArgs);
});
});
}
})();
};
BaseClass.prototype.addEventListenerOnce = function (eventName) {
var _this = this;
return (function () {
if (instanceAvailability(_this) === true) {
return getPromise(function (resolve) {
_this._objectInstance.one(eventName, function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var newArgs = normalizeArgumentsOfEventListener.call(_this, _this._objectInstance, args);
resolve(newArgs);
});
});
}
})();
};
BaseClass.prototype.addListenerOnce = function (eventName) {
var _this = this;
return (function () {
if (instanceAvailability(_this) === true) {
console.warn('[GoogleMaps] "addListenerOnce" is deprecated. Please use "addEventListenerOnce".');
return _this.addEventListenerOnce(eventName);
}
})();
};
BaseClass.prototype.get = function (key) { return cordovaInstance(this, "get", { "sync": true }, arguments); };
BaseClass.prototype.set = function (key, value, noNotify) { return cordovaInstance(this, "set", { "sync": true }, arguments); };
BaseClass.prototype.bindTo = function (key, target, targetKey, noNotify) { return cordovaInstance(this, "bindTo", { "sync": true }, arguments); };
BaseClass.prototype.on = function (eventName) {
var _this = this;
return (function () {
if (instanceAvailability(_this) === true) {
return new Observable(function (observer) {
_this._objectInstance.on(eventName, function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var newArgs = normalizeArgumentsOfEventListener.call(_this, _this._objectInstance, args);
observer.next(newArgs);
});
});
}
})();
};
BaseClass.prototype.one = function (eventName) {
var _this = this;
return (function () {
if (instanceAvailability(_this) === true) {
return getPromise(function (resolve) {
_this._objectInstance.one(eventName, function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var newArgs = normalizeArgumentsOfEventListener.call(_this, _this._objectInstance, args);
resolve(newArgs);
});
});
}
})();
};
BaseClass.prototype.hasEventListener = function () { return cordovaInstance(this, "hasEventListener", { "sync": true }, arguments); };
BaseClass.prototype.empty = function () { return cordovaInstance(this, "empty", { "sync": true }, arguments); };
BaseClass.prototype.trigger = function (eventName) {
var parameters = [];
for (var _i = 1; _i < arguments.length; _i++) {
parameters[_i - 1] = arguments[_i];
}
return cordovaInstance(this, "trigger", { "sync": true }, arguments);
};
BaseClass.prototype.destroy = function () { return cordovaInstance(this, "destroy", { "sync": true }, arguments); };
BaseClass.prototype.removeEventListener = function (eventName, listener) { return cordovaInstance(this, "removeEventListener", { "sync": true }, arguments); };
BaseClass.prototype.off = function (eventName, listener) { return cordovaInstance(this, "off", { "sync": true }, arguments); };
BaseClass.plugin = "cordova-plugin-googlemaps";
BaseClass.pluginName = "GoogleMaps";
BaseClass.pluginRef = "plugin.google.maps.BaseClass";
BaseClass.repo = "";
return BaseClass;
}());
export { BaseClass };
var BaseArrayClass = /** @class */ (function (_super) {
__extends(BaseArrayClass, _super);
function BaseArrayClass(initialData) {
var _this = this;
if (initialData instanceof GoogleMaps.getPlugin().BaseArrayClass) {
_this = _super.call(this, initialData) || this;
}
else if (Array.isArray(initialData)) {
_this = _super.call(this, new (GoogleMaps.getPlugin().BaseArrayClass)(initialData)) || this;
}
else {
_this = _super.call(this, new (GoogleMaps.getPlugin().BaseArrayClass)([])) || this;
}
return _this;
}
BaseArrayClass.prototype.empty = function (noNotify) { return cordovaInstance(this, "empty", { "sync": true }, arguments); };
BaseArrayClass.prototype.forEach = function (fn) { return cordovaInstance(this, "forEach", { "sync": true }, arguments); };
/**
* Iterate over each element, calling the provided callback.
* @param fn {Function}
* @return {Promise<void>}
*/
BaseArrayClass.prototype.forEachAsync = function (fn) {
var _this = this;
return getPromise(function (resolve) {
_this._objectInstance.forEach(fn, resolve);
});
};
BaseArrayClass.prototype.map = function (fn) { return cordovaInstance(this, "map", { "sync": true }, arguments); };
/**
* Iterate over each element, calling the provided callback.
* Then you can get the results of each callback.
* @param fn {Function}
* @param callback {Function}
* @return {Promise<any>} returns a new array with the results
*/
BaseArrayClass.prototype.mapAsync = function (fn) {
var _this = this;
return getPromise(function (resolve) {
_this._objectInstance.map(fn, resolve);
});
};
/**
* Same as `mapAsync`, but keep the execution order
* @param fn {Function}
* @param callback {Function}
* @return {Promise<any>} returns a new array with the results
*/
BaseArrayClass.prototype.mapSeries = function (fn) {
var _this = this;
return getPromise(function (resolve) {
_this._objectInstance.mapSeries(fn, resolve);
});
};
BaseArrayClass.prototype.filter = function (fn) { return cordovaInstance(this, "filter", { "sync": true }, arguments); };
/**
* The filterAsync() method creates a new array with all elements that pass the test implemented by the provided function.
* @param fn {Function}
* @param callback {Function}
* @return {Promise<T[]>} returns a new filtered array
*/
BaseArrayClass.prototype.filterAsync = function (fn) {
var _this = this;
return getPromise(function (resolve) {
_this._objectInstance.filter(fn, resolve);
});
};
BaseArrayClass.prototype.getArray = function () { return cordovaInstance(this, "getArray", { "sync": true }, arguments); };
BaseArrayClass.prototype.getAt = function (index) { return cordovaInstance(this, "getAt", { "sync": true }, arguments); };
BaseArrayClass.prototype.getLength = function () { return cordovaInstance(this, "getLength", { "sync": true }, arguments); };
BaseArrayClass.prototype.indexOf = function (element) { return cordovaInstance(this, "indexOf", { "sync": true }, arguments); };
BaseArrayClass.prototype.reverse = function () { return cordovaInstance(this, "reverse", { "sync": true }, arguments); };
BaseArrayClass.prototype.sort = function () { return cordovaInstance(this, "sort", { "sync": true }, arguments); };
BaseArrayClass.prototype.insertAt = function (index, element, noNotify) { return cordovaInstance(this, "insertAt", { "sync": true }, arguments); };
BaseArrayClass.prototype.pop = function (noNotify) { return cordovaInstance(this, "pop", { "sync": true }, arguments); };
BaseArrayClass.prototype.push = function (element, noNotify) { return cordovaInstance(this, "push", { "sync": true }, arguments); };
BaseArrayClass.prototype.removeAt = function (index, noNotify) { return cordovaInstance(this, "removeAt", { "sync": true }, arguments); };
BaseArrayClass.prototype.setAt = function (index, element, noNotify) { return cordovaInstance(this, "setAt", { "sync": true }, arguments); };
BaseArrayClass.pluginName = "BaseArrayClass";
BaseArrayClass.plugin = "cordova-plugin-googlemaps";
BaseArrayClass.pluginRef = "plugin.google.maps.BaseArrayClass";
return BaseArrayClass;
}(BaseClass));
export { BaseArrayClass };
var Circle = /** @class */ (function (_super) {
__extends(Circle, _super);
function Circle(_map, _objectInstance) {
var _this = _super.call(this, _objectInstance) || this;
_this._map = _map;
return _this;
}
Circle.prototype.getId = function () { return cordovaInstance(this, "getId", { "sync": true }, arguments); };
/**
* Returns the map instance.
* @return {GoogleMap}
*/
Circle.prototype.getMap = function () {
return this._map;
};
Circle.prototype.setCenter = function (latLng) { return cordovaInstance(this, "setCenter", { "sync": true }, arguments); };
Circle.prototype.getCenter = function () { return cordovaInstance(this, "getCenter", { "sync": true }, arguments); };
Circle.prototype.getRadius = function () { return cordovaInstance(this, "getRadius", { "sync": true }, arguments); };
Circle.prototype.setRadius = function (radius) { return cordovaInstance(this, "setRadius", { "sync": true }, arguments); };
Circle.prototype.setFillColor = function (color) { return cordovaInstance(this, "setFillColor", { "sync": true }, arguments); };
Circle.prototype.getFillColor = function () { return cordovaInstance(this, "getFillColor", { "sync": true }, arguments); };
Circle.prototype.setStrokeWidth = function (strokeWidth) { return cordovaInstance(this, "setStrokeWidth", { "sync": true }, arguments); };
Circle.prototype.getStrokeWidth = function () { return cordovaInstance(this, "getStrokeWidth", { "sync": true }, arguments); };
Circle.prototype.setStrokeColor = function (strokeColor) { return cordovaInstance(this, "setStrokeColor", { "sync": true }, arguments); };
Circle.prototype.getStrokeColor = function () { return cordovaInstance(this, "getStrokeColor", { "sync": true }, arguments); };
Circle.prototype.setClickable = function (clickable) { return cordovaInstance(this, "setClickable", { "sync": true }, arguments); };
Circle.prototype.getClickable = function () { return cordovaInstance(this, "getClickable", { "sync": true }, arguments); };
Circle.prototype.setZIndex = function (zIndex) { return cordovaInstance(this, "setZIndex", { "sync": true }, arguments); };
Circle.prototype.getZIndex = function () { return cordovaInstance(this, "getZIndex", { "sync": true }, arguments); };
Circle.prototype.remove = function () { return cordovaInstance(this, "remove", {}, arguments); };
Circle.prototype.getBounds = function () { return cordovaInstance(this, "getBounds", { "sync": true }, arguments); };
Circle.prototype.setVisible = function (visible) { return cordovaInstance(this, "setVisible", { "sync": true }, arguments); };
Circle.prototype.getVisible = function () { return cordovaInstance(this, "getVisible", { "sync": true }, arguments); };
return Circle;
}(BaseClass));
export { Circle };
var Environment = /** @class */ (function () {
function Environment() {
}
/**
* Set environment variables.
*/
Environment.setEnv = function (envOptions) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
GoogleMaps.getPlugin().environment.setEnv(envOptions);
};
/**
* Get the open source software license information for Google Maps SDK for iOS.
* @return {Promise<any>}
*/
Environment.getLicenseInfo = function () {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return getPromise(function (resolve) {
GoogleMaps.getPlugin().environment.getLicenseInfo(function (text) { return resolve(text); });
});
};
/**
* Specifies the background color of the app.
* @param color
*/
Environment.setBackgroundColor = function (color) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
GoogleMaps.getPlugin().environment.setBackgroundColor(color);
};
/**
* @deprecation This method is static. Please use Environment.getLicenseInfo()
* @hidden
*/
Environment.prototype.getLicenseInfo = function () {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Environment.getLicenseInfo()');
return Environment.getLicenseInfo();
};
/**
* @deprecation This method is static. Please use Environment.setBackgroundColor()
* @hidden
*/
Environment.prototype.setBackgroundColor = function (color) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Environment.setBackgroundColor()');
Environment.setBackgroundColor(color);
};
Environment.plugin = "cordova-plugin-googlemaps";
Environment.pluginName = "GoogleMaps";
Environment.pluginRef = "plugin.google.maps.environment";
Environment.repo = "";
return Environment;
}());
export { Environment };
var Geocoder = /** @class */ (function () {
function Geocoder() {
}
/**
* @deprecation This method is static. Please use Geocoder.geocode()
* @hidden
*/
Geocoder.prototype.geocode = function (request) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Geocoder.geocode()');
return Geocoder.geocode(request);
};
/**
* Converts position to address and vice versa
* @param {GeocoderRequest} request Request object with either an address or a position
* @return {Promise<GeocoderResult[] | BaseArrayClass<GeocoderResult>>}
*/
Geocoder.geocode = function (request) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
if (request.address instanceof Array || Array.isArray(request.address) ||
request.position instanceof Array || Array.isArray(request.position)) {
// -------------------------
// Geocoder.geocode({
// address: [
// "Kyoto, Japan",
// "Tokyo, Japan"
// ]
// })
// -------------------------
return getPromise(function (resolve, reject) {
GoogleMaps.getPlugin().Geocoder.geocode(request, function (mvcArray) {
if (mvcArray) {
resolve(new BaseArrayClass(mvcArray));
}
else {
reject();
}
});
});
}
else {
// -------------------------
// Geocoder.geocode({
// address: "Kyoto, Japan"
// })
// -------------------------
return getPromise(function (resolve, reject) {
GoogleMaps.getPlugin().Geocoder.geocode(request, function (results) {
if (results) {
resolve(results);
}
else {
reject();
}
});
});
}
};
Geocoder.pluginName = "GoogleMaps";
Geocoder.pluginRef = "plugin.google.maps.Geocoder";
Geocoder.plugin = "cordova-plugin-googlemaps";
Geocoder.repo = "";
return Geocoder;
}());
export { Geocoder };
var LocationService = /** @class */ (function () {
function LocationService() {
}
/**
* Get the current device location without map
* @return {Promise<MyLocation>}
*/
LocationService.getMyLocation = function (options) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return getPromise(function (resolve, reject) {
GoogleMaps.getPlugin().LocationService.getMyLocation(options, resolve, reject);
});
};
/**
* Return true if the application has geolocation permission
* @return {Promise<boolean>}
*/
LocationService.hasPermission = function () {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return getPromise(function (resolve, reject) {
GoogleMaps.getPlugin().LocationService.hasPermission(resolve, reject);
});
};
LocationService.pluginName = "GoogleMaps";
LocationService.pluginRef = "plugin.google.maps.LocationService";
LocationService.plugin = "cordova-plugin-googlemaps";
LocationService.repo = "";
return LocationService;
}());
export { LocationService };
var Encoding = /** @class */ (function () {
function Encoding() {
}
/**
* Decodes an encoded path string into a sequence of LatLngs.
* @param encoded {string} an encoded path string
* @param precision? {number} default: 5
* @return {LatLng}
*/
Encoding.decodePath = function (encoded, precision) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().encoding.decodePath(encoded, precision);
};
/**
* Encodes a sequence of LatLngs into an encoded path string.
* @param path {ILatLng[] | BaseArrayClass<ILatLng>} a sequence of LatLngs
* @return {string}
*/
Encoding.encodePath = function (path) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().encoding.encodePath(path);
};
/**
* @deprecation This method is static. Please use Encoding.decodePath()
* @hidden
*/
Encoding.prototype.decodePath = function (encoded, precision) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Encoding.decodePath()');
return Encoding.decodePath(encoded, precision);
};
/**
* @deprecation This method is static. Please use Encoding.encodePath()
* @hidden
*/
Encoding.prototype.encodePath = function (path) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Encoding.encodePath()');
return Encoding.encodePath(path);
};
Encoding.pluginName = "GoogleMaps";
Encoding.pluginRef = "plugin.google.maps.geometry.encoding";
Encoding.plugin = "cordova-plugin-googlemaps";
Encoding.repo = "";
return Encoding;
}());
export { Encoding };
var Poly = /** @class */ (function () {
function Poly() {
}
/**
* Returns true if the specified location is in the polygon path
* @param location {ILatLng}
* @param path {ILatLng[]}
* @return {boolean}
*/
Poly.containsLocation = function (location, path) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.poly.containsLocation(location, path);
};
/**
* Returns true if the specified location is on the polyline path
* @param location {ILatLng}
* @param path {ILatLng[]}
* @return {boolean}
*/
Poly.isLocationOnEdge = function (location, path) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.poly.isLocationOnEdge(location, path);
};
Poly.pluginName = "GoogleMaps";
Poly.pluginRef = "plugin.google.maps.geometry.poly";
Poly.plugin = "cordova-plugin-googlemaps";
Poly.repo = "";
return Poly;
}());
export { Poly };
var Spherical = /** @class */ (function () {
function Spherical() {
}
/**
* Returns the distance, in meters, between two LatLngs.
* @param locationA {ILatLng}
* @param locationB {ILatLng}
* @return {number}
*/
Spherical.computeDistanceBetween = function (from, to) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeDistanceBetween(from, to);
};
/**
* Returns the LatLng resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north)
* @param from {ILatLng}
* @param distance {number}
* @param heading {number}
* @return {LatLng}
*/
Spherical.computeOffset = function (from, distance, heading) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeOffset(from, distance, heading);
};
/**
* Returns the location of origin when provided with a LatLng destination, meters travelled and original heading. Headings are expressed in degrees clockwise from North. This function returns null when no solution is available.
* @param to {ILatLng} The destination LatLng.
* @param distance {number} The distance travelled, in meters.
* @param heading {number} The heading in degrees clockwise from north.
* @return {LatLng}
*/
Spherical.computeOffsetOrigin = function (to, distance, heading) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeOffsetOrigin(to, distance, heading);
};
/**
* Returns the length of the given path.
* @param path {ILatLng[] | BaseArrayClass<ILatLng>}
* @return {number}
*/
Spherical.computeLength = function (path) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeLength(path);
};
/**
* Returns the area of a closed path. The computed area uses the same units as the radius.
* @param path {ILatLng[] | BaseArrayClass<ILatLng>}.
* @return {number}
*/
Spherical.computeArea = function (path) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeLength(path);
};
/**
* Returns the signed area of a closed path. The signed area may be used to determine the orientation of the path.
* @param path {ILatLng[] | BaseArrayClass<ILatLng>}.
* @return {number}
*/
Spherical.computeSignedArea = function (path) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeSignedArea(path);
};
/**
* Returns the heading from one LatLng to another LatLng. Headings are expressed in degrees clockwise from North within the range (-180,180).
* @param from {ILatLng}
* @param to {ILatLng}
* @return {number}
*/
Spherical.computeHeading = function (from, to) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.computeHeading(from, to);
};
/**
* Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng.
* @param from {ILatLng} The LatLng from which to start.
* @param to {ILatLng} The LatLng toward which to travel.
* @param fraction {number} A fraction of the distance to travel from 0.0 to 1.0 .
* @return {LatLng}
*/
Spherical.interpolate = function (from, to, fraction) {
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === false) {
throw new Error('cordova-plugin-googlemaps is not ready. Please use platform.ready() before accessing this method.');
}
return GoogleMaps.getPlugin().geometry.spherical.interpolate(from, to, fraction);
};
/**
* @deprecation This method is static. Please use Spherical.computeDistanceBetween()
* @hidden
*/
Spherical.prototype.computeDistanceBetween = function (from, to) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeDistanceBetween()');
return Spherical.computeDistanceBetween(from, to);
};
/**
* @deprecation This method is static. Please use Spherical.computeOffset()
* @hidden
*/
Spherical.prototype.computeOffset = function (from, distance, heading) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeOffset()');
return Spherical.computeOffset(from, distance, heading);
};
/**
* @deprecation This method is static. Please use Spherical.computeOffsetOrigin()
* @hidden
*/
Spherical.prototype.computeOffsetOrigin = function (to, distance, heading) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeOffsetOrigin()');
return Spherical.computeOffsetOrigin(to, distance, heading);
};
/**
* @deprecation This method is static. Please use Spherical.computeLength()
* @hidden
*/
Spherical.prototype.computeLength = function (path) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeLength()');
return Spherical.computeLength(path);
};
/**
* @deprecation This method is static. Please use Spherical.computeArea()
* @hidden
*/
Spherical.prototype.computeArea = function (path) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeArea()');
return Spherical.computeArea(path);
};
/**
* @deprecation This method is static. Please use Spherical.computeSignedArea()
* @hidden
*/
Spherical.prototype.computeSignedArea = function (path) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeSignedArea()');
return Spherical.computeSignedArea(path);
};
/**
* @deprecation This method is static. Please use Spherical.computeHeading()
* @hidden
*/
Spherical.prototype.computeHeading = function (from, to) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeHeading()');
return Spherical.computeHeading(from, to);
};
/**
* @deprecation This method is static. Please use Spherical.interpolate()
* @hidden
*/
Spherical.prototype.interpolate = function (from, to, fraction) {
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.interpolate()');
return Spherical.interpolate(from, to, fraction);
};
Spherical.pluginName = "GoogleMaps";
Spherical.pluginRef = "plugin.google.maps.geometry.spherical";
Spherical.plugin = "cordova-plugin-googlemaps";
Spherical.repo = "";
return Spherical;
}());
export { Spherical };
var StreetViewPanorama = /** @class */ (function (_super) {
__extends(StreetViewPanorama, _super);
function StreetViewPanorama(element, options) {
var _this = this;
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
// -------------------
// Create a panorama
// -------------------
if (element instanceof HTMLElement) {
if (element.offsetWidth >= 100 && element.offsetHeight >= 100) {
_this = _super.call(this, GoogleMaps.getPlugin().StreetView.getPanorama(element, options)) || this;
}
else {
throw new Error(element.tagName + ' is too small. Must be bigger than 100x100.');
}
}
else if (typeof element === 'string') {
_this = _super.call(this, GoogleMaps.getPlugin().StreetView.getPanorama(getPromise(function (resolve, reject) {
var count;
var i;
count = 0;
var timer = setInterval(function () {
var targets;
for (i = 0; i < TARGET_ELEMENT_FINDING_QUERYS.length; i++) {
targets = Array.from(document.querySelectorAll(TARGET_ELEMENT_FINDING_QUERYS[i] + element));
if (targets.length > 0) {
targets = targets.filter(function (target) {
return !target.hasAttribute('__pluginmapid');
});
}
if (targets.length === 1 && targets[0] && targets[0].offsetWidth >= 100 && targets[0].offsetHeight >= 100) {
clearInterval(timer);
resolve([targets[0], options]);
return;
}
}
if (count++ < 20) {
return;
}
clearInterval(timer);
_this._objectInstance.remove();
if (targets.length > 0 && targets[0] && targets[0].offsetWidth < 100 || targets[0].offsetHeight < 100) {
reject(new Error(targets[0].tagName + '[#' + element + '] is too small. Must be bigger than 100x100.'));
}
else {
if (targets.length > 1) {
reject(new Error('There are multiple "' + element + '" elements. Use different id to prevent error.'));
}
else {
reject(new Error('Can not find the element [#' + element + ']'));
}
}
}, 100);
}), options)) || this;
}
}
else {
var errorMessage = [
'[GoogleMaps]'
];
if (!window.cordova) {
errorMessage.push('You need to execute "$> ionic cordova run browser".');
errorMessage.push('"$> ionic serve" is not supported.');
}
else {
errorMessage.push('cordova-plugin-googlemaps is not installed or not ready yet.');
}
if (element instanceof HTMLElement) {
displayErro