mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-24 14:11:18 +08:00
working!
This commit is contained in:
parent
6b5f216fa4
commit
f3509689db
@ -36,8 +36,18 @@ declare var plugin: any;
|
|||||||
repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps'
|
repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps'
|
||||||
})
|
})
|
||||||
export class GoogleMap {
|
export class GoogleMap {
|
||||||
|
static event: any = {
|
||||||
private _objectInstance: any;
|
MAP_READY: plugin.google.maps.event.MAP_READY,
|
||||||
|
MAP_CLICK: plugin.google.maps.event.MAP_CLICK,
|
||||||
|
MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK,
|
||||||
|
MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK,
|
||||||
|
CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE,
|
||||||
|
CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE,
|
||||||
|
MAP_LOADED: plugin.google.maps.event.MAP_LOADED,
|
||||||
|
MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE,
|
||||||
|
MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE
|
||||||
|
};
|
||||||
|
_objectInstance: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a map object has been created.
|
* Checks if a map object has been created.
|
||||||
@ -50,32 +60,21 @@ export class GoogleMap {
|
|||||||
this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId));
|
this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
on(event: any): Observable<any>{
|
||||||
* Get notified via an Observable when the user clicks on the map. (Event: MAP_CLICK)
|
return new Observable(
|
||||||
*/
|
(observer) => {
|
||||||
@Cordova({
|
this._objectInstance.on(event, observer.next);
|
||||||
eventObservable: true,
|
return () => this._objectInstance.off(event);
|
||||||
event: 'plugin.google.maps.event.MAP_CLICK'
|
}
|
||||||
})
|
);
|
||||||
static onMapClick (): Observable<GoogleMapsLatLng> {return; }
|
}
|
||||||
|
|
||||||
/**
|
one(event: any): Promise<any>{
|
||||||
* Get notified via an Observable when the user long-clicks on the map. (Event: MAP_LONG_CLICK)
|
return new Promise<any>(
|
||||||
*/
|
resolve => this._objectInstance.one(event, resolve)
|
||||||
@Cordova({
|
);
|
||||||
eventObservable: true,
|
}
|
||||||
event: 'plugin.google.maps.event.MAP_LONG_CLICK'
|
|
||||||
})
|
|
||||||
static onMapLongClick (): Observable<GoogleMapsLatLng> {return; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get notified via an Observable when the user clicks the `My Location` button. (Event: MY_LOCATION_BUTTON_CLICK)
|
|
||||||
*/
|
|
||||||
@Cordova({
|
|
||||||
eventObservable: true,
|
|
||||||
event: 'plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK'
|
|
||||||
})
|
|
||||||
static onMyLocationButtonClick (): Observable<any> {return; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notified via an Observable when the user changes the view. (Event: CAMERA_CHANGE)
|
* Get notified via an Observable when the user changes the view. (Event: CAMERA_CHANGE)
|
||||||
@ -230,9 +229,15 @@ export class GoogleMap {
|
|||||||
})
|
})
|
||||||
setAllGesturesEnabled (enabled: boolean): void { }
|
setAllGesturesEnabled (enabled: boolean): void { }
|
||||||
|
|
||||||
addMarker (options: GoogleMapsMarkerOptions): GoogleMapsMarker {
|
addMarker (options: GoogleMapsMarkerOptions): Promise<GoogleMapsMarker> {
|
||||||
let objectInstance: any = this._objectInstance.addMarker(options);
|
return new Promise<GoogleMapsMarker>(
|
||||||
return new GoogleMapsMarker(objectInstance);
|
(resolve, reject) => {
|
||||||
|
this._objectInstance.addMarker(options, (marker: any) => {
|
||||||
|
if(marker) resolve(new GoogleMapsMarker(marker));
|
||||||
|
else reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCircle (options: GoogleMapsCircleOptions): GoogleMapsCircle {
|
addCircle (options: GoogleMapsCircleOptions): GoogleMapsCircle {
|
||||||
@ -317,54 +322,54 @@ export class GoogleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AnimateCameraOptions {
|
export interface AnimateCameraOptions {
|
||||||
target: string;
|
target?: string;
|
||||||
tilt: number;
|
tilt?: number;
|
||||||
zoom: number;
|
zoom?: number;
|
||||||
bearing: number;
|
bearing?: number;
|
||||||
duration: number;
|
duration?: number;
|
||||||
}
|
}
|
||||||
export interface CameraPosition {
|
export interface CameraPosition {
|
||||||
target: {
|
target?: {
|
||||||
lat: string;
|
lat?: string;
|
||||||
lng: string;
|
lng?: string;
|
||||||
};
|
};
|
||||||
zoom: number;
|
zoom?: number;
|
||||||
tilt: number;
|
tilt?: number;
|
||||||
bearing: number;
|
bearing?: number;
|
||||||
}
|
}
|
||||||
export interface MyLocation {
|
export interface MyLocation {
|
||||||
latLng: {
|
latLng?: {
|
||||||
lat: string;
|
lat?: string;
|
||||||
lng: string;
|
lng?: string;
|
||||||
};
|
};
|
||||||
speed: number;
|
speed?: number;
|
||||||
time: string;
|
time?: string;
|
||||||
bearing: number;
|
bearing?: number;
|
||||||
}
|
}
|
||||||
export interface VisibleRegion {
|
export interface VisibleRegion {
|
||||||
northeast: any;
|
northeast?: any;
|
||||||
southwest: any;
|
southwest?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GoogleMapsMarkerOptions {
|
export interface GoogleMapsMarkerOptions {
|
||||||
icon: any;
|
icon?: any;
|
||||||
title: string;
|
title?: string;
|
||||||
snippet: string;
|
snippet?: string;
|
||||||
position: GoogleMapsLatLng;
|
position?: GoogleMapsLatLng;
|
||||||
infoWindowAnchor: number[];
|
infoWindowAnchor?: number[];
|
||||||
draggable: boolean;
|
draggable?: boolean;
|
||||||
flat: boolean;
|
flat?: boolean;
|
||||||
rotation: number;
|
rotation?: number;
|
||||||
visible: boolean;
|
visible?: boolean;
|
||||||
styles: any;
|
styles?: any;
|
||||||
animation: string;
|
animation?: string;
|
||||||
zIndex: number;
|
zIndex?: number;
|
||||||
}
|
}
|
||||||
export interface GoogleMapsMarkerIcon {
|
export interface GoogleMapsMarkerIcon {
|
||||||
url: string;
|
url?: string;
|
||||||
size: {
|
size?: {
|
||||||
width: number;
|
width?: number;
|
||||||
height: number;
|
height?: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class GoogleMapsMarker {
|
export class GoogleMapsMarker {
|
||||||
@ -497,13 +502,13 @@ export class GoogleMapsMarker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GoogleMapsCircleOptions {
|
export interface GoogleMapsCircleOptions {
|
||||||
center: GoogleMapsLatLng;
|
center?: GoogleMapsLatLng;
|
||||||
radius: number;
|
radius?: number;
|
||||||
strokeColor: string;
|
strokeColor?: string;
|
||||||
strokeWidth: number;
|
strokeWidth?: number;
|
||||||
fillColor: string;
|
fillColor?: string;
|
||||||
visible: boolean;
|
visible?: boolean;
|
||||||
zIndex: number;
|
zIndex?: number;
|
||||||
}
|
}
|
||||||
export class GoogleMapsCircle {
|
export class GoogleMapsCircle {
|
||||||
|
|
||||||
@ -584,12 +589,12 @@ export class GoogleMapsCircle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GoogleMapsPolylineOptions {
|
export interface GoogleMapsPolylineOptions {
|
||||||
points: Array<GoogleMapsLatLng>;
|
points?: Array<GoogleMapsLatLng>;
|
||||||
visible: boolean;
|
visible?: boolean;
|
||||||
googledesic: boolean;
|
googledesic?: boolean;
|
||||||
color: string;
|
color?: string;
|
||||||
width: number;
|
width?: number;
|
||||||
zIndex: number;
|
zIndex?: number;
|
||||||
}
|
}
|
||||||
export class GoogleMapsPolyline {
|
export class GoogleMapsPolyline {
|
||||||
constructor (private _objectInstance: any) { }
|
constructor (private _objectInstance: any) { }
|
||||||
@ -641,7 +646,7 @@ export class GoogleMapsLatLng {
|
|||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
|
|
||||||
constructor (public lat: string, public lng: string) {
|
constructor (public lat: string, public lng: string) {
|
||||||
this._objectInstance = plugin.google.maps.LatLng(lat, lng);
|
this._objectInstance = new plugin.google.maps.LatLng(lat, lng);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user