Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return getPromise>((resolve, reject) => {
GoogleMaps.getPlugin().Geocoder.geocode(request, (mvcArray: any) => {
if (mvcArray) {
resolve(new BaseArrayClass(mvcArray));
} else {
reject();
}
});
});
} else {
// -------------------------
// Geocoder.geocode({
// address: "Kyoto, Japan"
// })
// -------------------------
return getPromise((resolve, reject) => {
GoogleMaps.getPlugin().Geocoder.geocode(request, (results: GeocoderResult[]) => {
if (results) {
resolve(results);
} else {
reject();
}
});
});
}
}
if (checkAvailability(GoogleMaps.getPluginRef(), null, GoogleMaps.getPluginName()) === true) {
// ---------------
// Create a map
// ---------------
if (element instanceof HTMLElement) {
if (!element.offsetParent) {
throw new Error('Element must be under ');
}
if (element.offsetWidth >= 100 && element.offsetHeight >= 100) {
super(GoogleMaps.getPlugin().Map.getMap(element, options));
} else {
throw new Error(element.tagName + ' is too small. Must be bigger than 100x100.');
}
} else if (typeof element === 'string') {
super(GoogleMaps.getPlugin().Map.getMap(getPromise((resolve, reject) => {
let count: number;
let i: number;
count = 0;
const timer: any = setInterval(() => {
let targets: any[];
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((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;
addGroundOverlay(options: GroundOverlayOptions): Promise {
return getPromise((resolve, reject) => {
this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
if (groundOverlay) {
const overlayId: string = groundOverlay.getId();
const overlay = new GroundOverlay(this, groundOverlay);
this.get('_overlays')[overlayId] = overlay;
groundOverlay.one(overlayId + '_remove', () => {
if (this.get('_overlays')) {
this.get('_overlays')[overlayId] = null;
overlay.destroy();
}
});
resolve(overlay);
} else {
reject();
}
});
addKmlOverlay(options: KmlOverlayOptions): Promise {
return getPromise((resolve, reject) => {
this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => {
if (kmlOverlay) {
const overlayId: string = kmlOverlay.getId();
const overlay = new KmlOverlay(this, kmlOverlay);
this.get('_overlays')[overlayId] = overlay;
kmlOverlay.one(overlayId + '_remove', () => {
if (this.get('_overlays')) {
this.get('_overlays')[overlayId] = null;
overlay.destroy();
}
});
resolve(overlay);
} else {
reject();
}
});
create(store: string): Promise {
return getPromise((res: Function, rej: Function) => {
const instance = new (SecureStorage.getPlugin())(
() => res(new SecureStorageObject(instance)),
rej,
store
);
});
}
}
forEachAsync(fn: ((element: T, callback: () => void) => void)): Promise {
return getPromise((resolve) => {
this._objectInstance.forEach(fn, resolve);
});
}
pickContact(): Promise {
return getPromise((resolve: Function, reject: Function) => {
navigator.contacts.pickContact(
(contact: any) => resolve(processContact(contact)),
reject
);
});
}
}
one(eventName: string): Promise {
return getPromise((resolve) => {
this._objectInstance.one(eventName, (...args: any[]) => {
const newArgs = normalizeArgumentsOfEventListener.call(this, this._objectInstance, args);
resolve(newArgs);
});
});
}
hasClient(app?: string): Promise {
return getPromise((resolve) => {
if (app) {
EmailComposer.getPlugin().hasClient(app, (result: boolean) => {
if (result) {
resolve(true);
} else {
resolve(false);
}
});
} else {
EmailComposer.getPlugin().getClients((apps: string[]) => {
resolve(apps.length && apps.length > 0);
});
}
});
}
wrap(functionName: string, args: any[]): Promise {
const plugin = WonderPush.getPlugin();
const userPreferences = plugin ? plugin.UserPreferences : null;
if (!plugin || !userPreferences || !userPreferences[functionName]) {
return getPromise((res, rej) => {
rej(new Error('Could not find plugin'));
});
}
return getPromise((res, rej) => {
userPreferences[functionName].apply(userPreferences, [ ...args, res]);
});
}