ng2-bingmaps
Version:
Angular 2 components for Bing Maps
1,152 lines (1,107 loc) • 59.8 kB
JavaScript
System.registerDynamic("angular2-google-maps/directives/bing-map.js", ["@angular/core", "../services/bing-maps-api-wrapper", "../services/marker-manager", "../services/info-window-manager"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var bing_maps_api_wrapper_1 = $__require("../services/bing-maps-api-wrapper");
var marker_manager_1 = $__require("../services/marker-manager");
var info_window_manager_1 = $__require("../services/info-window-manager");
/**
* BingMap renders a Bing Map.
* **Important note**: To be able see a map in the browser, you have to define a height for the CSS
* class `bing-map-container`.
*
* ### Example
* ```typescript
* import {Component} from '@angular/core';
* import {BingMap} from 'ng2-bingmaps/directives';
*
* @Component({
* selector: 'my-map-cmp',
* directives: [BingMap],
* styles: [`
* .bing-map-container {
* height: 300px;
* }
* `],
* template: `
* <sebm-google-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
* </sebm-google-map>
* `
* })
* ```
*/
var BingMap = function () {
function BingMap(_elem, _mapsWrapper) {
this._elem = _elem;
this._mapsWrapper = _mapsWrapper;
this._longitude = 0;
this._latitude = 0;
this._zoom = 8;
/**
* Enables/disables zoom and center on double click. Enabled by default.
*/
this.disableDoubleClickZoom = false;
/**
* If false, disables scrollwheel zooming on the map. The scrollwheel is enabled by default.
*/
this.scrollwheel = true;
/**
* If false, prevents the map from being controlled by the keyboard. Keyboard shortcuts are
* enabled by default.
*/
this.keyboardShortcuts = true;
/**
* The enabled/disabled state of the Zoom control.
*/
this.zoomControl = true;
/**
* This event emitter gets emitted when the user clicks on the map (but not when they click on a
* marker or infoWindow).
*/
this.mapClick = new core_1.EventEmitter();
/**
* This event emitter gets emitted when the user right-clicks on the map (but not when they click
* on a marker or infoWindow).
*/
this.mapRightClick = new core_1.EventEmitter();
/**
* This event emitter gets emitted when the user double-clicks on the map (but not when they click
* on a marker or infoWindow).
*/
this.mapDblClick = new core_1.EventEmitter();
/**
* This event emitter is fired when the map center changes.
*/
this.centerChange = new core_1.EventEmitter();
/**
* A reference to the native Microsoft.Maps.Map element
*/
this.nativeMap = null;
this.nativeMapChange = new core_1.EventEmitter();
}
/** @internal */
BingMap.prototype.ngOnInit = function () {
var container = this._elem.nativeElement.querySelector('.bing-map-container-inner');
this._initMapInstance(container);
};
BingMap.prototype._initMapInstance = function (el) {
var _this = this;
this._mapsWrapper.createMap(el, {
center: { lat: this._latitude, lng: this._longitude },
zoom: this._zoom
}).then(function (map) {
_this.nativeMap = map;
_this.nativeMapChange.emit(map);
});
};
/* @internal */
BingMap.prototype.ngOnChanges = function (changes) {
// if (changes['latitude']) {
// this.latitude = changes['latitude'];
// this._markerManager.updateMarkerPosition(this);
// }
this._updateMapOptionsChanges(changes);
};
BingMap.prototype._updateMapOptionsChanges = function (changes) {
var options = {};
var optionKeys = Object.keys(changes).filter(function (k) {
return BingMap._mapOptionsAttributes.indexOf(k) !== -1;
});
optionKeys.forEach(function (k) {
options[k] = changes[k].currentValue;
});
// todo this._mapsWrapper.setMapOptions(options);
};
/**
* Triggers a resize event on the google map instance.
* Returns a promise that gets resolved after the event was triggered.
*/
BingMap.prototype.triggerResize = function () {
var _this = this;
// Note: When we would trigger the resize event and show the map in the same turn (which is a
// common case for triggering a resize event), then the resize event would not
// work (to show the map), so we trigger the event in a timeout.
return new Promise(function (resolve) {
setTimeout(function () {
return _this._mapsWrapper.triggerMapEvent('resize').then(function () {
return resolve();
});
});
});
};
Object.defineProperty(BingMap.prototype, "zoom", {
/**
* Sets the zoom level of the map. The default value is `8`.
*/
set: function (value) {
this._zoom = this._convertToDecimal(value, 8);
if (typeof this._zoom === 'number') {
this._mapsWrapper.setZoom(this._zoom);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(BingMap.prototype, "longitude", {
/**
* The longitude that sets the center of the map.
*/
set: function (value) {
this._longitude = this._convertToDecimal(value);
this._updateCenter();
},
enumerable: true,
configurable: true
});
Object.defineProperty(BingMap.prototype, "latitude", {
/**
* The latitude that sets the center of the map.
*/
set: function (value) {
this._latitude = this._convertToDecimal(value);
this._updateCenter();
},
enumerable: true,
configurable: true
});
BingMap.prototype._convertToDecimal = function (value, defaultValue) {
if (defaultValue === void 0) {
defaultValue = null;
}
if (typeof value === 'string') {
return parseFloat(value);
} else if (typeof value === 'number') {
return value;
}
return defaultValue;
};
BingMap.prototype._updateCenter = function () {
if (typeof this._latitude !== 'number' || typeof this._longitude !== 'number') {
return;
}
this._mapsWrapper.setCenter({
lat: this._latitude,
lng: this._longitude
});
};
/**
* Map option attributes that can change over time
*/
BingMap._mapOptionsAttributes = [];
BingMap = __decorate([core_1.Component({
selector: 'bing-map',
providers: [bing_maps_api_wrapper_1.BingMapsAPIWrapper, marker_manager_1.MarkerManager, info_window_manager_1.InfoWindowManager],
inputs: ['longitude', 'latitude', 'zoom', 'disableDoubleClickZoom', 'disableDefaultUI', 'scrollwheel', 'backgroundColor', 'draggableCursor', 'draggingCursor', 'keyboardShortcuts', 'zoomControl', 'nativeMap'],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange', 'nativeMapChange'],
host: { '[class.bing-map-container]': 'true' },
styles: ["\n .bing-map-container-inner {\n width: inherit;\n height: inherit;\n }\n .bing-map-content {\n display:none;\n }\n "],
template: "\n <div class='bing-map-container-inner'></div>\n <div class='bing-map-content'>\n <ng-content></ng-content>\n </div>\n "
}), __metadata('design:paramtypes', [core_1.ElementRef, bing_maps_api_wrapper_1.BingMapsAPIWrapper])], BingMap);
return BingMap;
}();
exports.BingMap = BingMap;
return module.exports;
});
System.registerDynamic("angular2-google-maps/directives/bing-map-marker.js", ["@angular/core", "../services/marker-manager", "./bing-map-info-window"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var marker_manager_1 = $__require("../services/marker-manager");
var bing_map_info_window_1 = $__require("./bing-map-info-window");
var markerId = 0;
/**
* SebmGoogleMapMarker renders a map marker inside a {@link SebmGoogleMap}.
*
* ### Example
* ```typescript
* import {Component} from 'angular2/core';
* import {SebmGoogleMap, SebmGoogleMapMarker} from 'angular2-google-maps/core';
*
* @Component({
* selector: 'my-map-cmp',
* directives: [SebmGoogleMap, SebmGoogleMapMarker],
* styles: [`
* .sebm-google-map-container {
* height: 300px;
* }
* `],
* template: `
* <sebm-google-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
* <sebm-google-map-marker [latitude]="lat" [longitude]="lng" [label]="'M'">
* </sebm-google-map-marker>
* </sebm-google-map>
* `
* })
* ```
*/
var BingMapMarker = function () {
function BingMapMarker(_markerManager) {
this._markerManager = _markerManager;
/**
* If true, the marker can be dragged. Default value is false.
*/
this.draggable = false;
/**
* This event emitter gets emitted when the user clicks on the marker.
*/
this.markerClick = new core_1.EventEmitter();
/**
* This event is fired when the user stops dragging the marker.
*/
this.dragEnd = new core_1.EventEmitter();
this._markerAddedToManger = false;
this._id = (markerId++).toString();
}
/* @internal */
BingMapMarker.prototype.ngAfterContentInit = function () {
if (this._infoWindow != null) {
this._infoWindow.hostMarker = this;
if (typeof this._infoWindow.latitude !== 'number' || typeof this._infoWindow.longitude !== 'number') {
// infowindow does not have lat and/or long. Set from marker values.
this._infoWindow.latitude = this.latitude;
this._infoWindow.longitude = this.longitude;
}
}
};
/** @internal */
BingMapMarker.prototype.ngOnChanges = function (changes) {
if (typeof this.latitude !== 'number' || typeof this.longitude !== 'number') {
return;
}
if (!this._markerAddedToManger) {
this._markerManager.addMarker(this);
this._markerAddedToManger = true;
this._addEventListeners();
return;
}
if (changes['latitude'] || changes['longitude']) {
this._markerManager.updateMarkerPosition(this);
if (typeof this._infoWindow !== 'undefined') {
this._infoWindow.latitude = this.latitude;
this._infoWindow.longitude = this.longitude;
}
}
if (changes['title']) {
this._markerManager.updateTitle(this);
}
if (changes['label']) {
this._markerManager.updateLabel(this);
}
if (changes['draggable']) {
this._markerManager.updateDraggable(this);
}
if (changes['iconUrl']) {
this._markerManager.updateIcon(this);
}
};
BingMapMarker.prototype._addEventListeners = function () {
var _this = this;
this._markerManager.createEventObservable('click', this).subscribe(function () {
if (_this._infoWindow != null) {
_this._infoWindow.open();
}
_this.markerClick.next(null);
});
};
/** @internal */
BingMapMarker.prototype.id = function () {
return this._id;
};
/** @internal */
BingMapMarker.prototype.toString = function () {
return 'BingMapMarker-' + this._id.toString();
};
/** @internal */
BingMapMarker.prototype.ngOnDestroy = function () {
this._markerManager.deleteMarker(this);
};
__decorate([core_1.ContentChild(bing_map_info_window_1.BingMapInfoWindow), __metadata('design:type', bing_map_info_window_1.BingMapInfoWindow)], BingMapMarker.prototype, "_infoWindow", void 0);
BingMapMarker = __decorate([core_1.Directive({
selector: 'bing-map-marker',
inputs: ['latitude', 'longitude', 'title', 'label', 'draggable: markerDraggable', 'iconUrl'],
outputs: ['markerClick', 'dragEnd']
}), __metadata('design:paramtypes', [marker_manager_1.MarkerManager])], BingMapMarker);
return BingMapMarker;
}();
exports.BingMapMarker = BingMapMarker;
return module.exports;
});
System.registerDynamic("angular2-google-maps/directives/bing-map-info-window.js", ["@angular/core", "../services/info-window-manager", "./bing-map-info-window-action"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var info_window_manager_1 = $__require("../services/info-window-manager");
var bing_map_info_window_action_1 = $__require("./bing-map-info-window-action");
var infoWindowId = 0;
/**
* BingMapInfoWindow renders a info window inside a {@link BingMapMarker} or standalone.
*
* ### Example
* ```typescript
* import {Component} from '@angular/core';
* import {NG2_BINGMAPS_DIRECTIVES} from 'ng2-bingmaps/core';
*
* @Component({
* selector: 'my-map-cmp',
* directives: [NG2_BINGMAPS_DIRECTIVES],
* styles: [`
* .bing-map-container {
* height: 300px;
* }
* `],
* template: `
* <bing-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
* <bing-map-marker [latitude]="lat" [longitude]="lng" [label]="'M'">
* <bing-map-info-window [title]="title" [description]="description" [height]="height" [width]="width">
* </bing-map-info-window>
* </bing-map-marker>
* </bing-map>
* `
* })
* ```
*/
var BingMapInfoWindow = function () {
function BingMapInfoWindow(_infoWindowManager) {
this._infoWindowManager = _infoWindowManager;
/**
* Emits an event when the info window is closed.
*/
this.infoWindowClose = new core_1.EventEmitter();
this._id = (infoWindowId++).toString();
}
/** @internal */
BingMapInfoWindow.prototype.ngOnChanges = function (changes) {
// todo check if opened, ask the infowindowmanager
// then implement below.
// if ((changes['latitude'] || changes['longitude']) && typeof this.latitude === 'number' &&
// typeof this.longitude === 'number') {
// this._infoWindowManager.setPosition(this);
// }
// this._setInfoWindowOptions(changes);
};
// private _setInfoWindowOptions(changes: {[key: string]: SimpleChange}) {
// let options: {[propName: string]: any} = {};
// let optionKeys = Object.keys(changes).filter(
// k => BingMapInfoWindow._infoWindowOptionsInputs.indexOf(k) !== -1);
// optionKeys.forEach((k) => { options[k] = changes[k].currentValue; });
// this._infoWindowManager.setOptions(options);
// }
/**
* Opens the info window.
*/
BingMapInfoWindow.prototype.open = function () {
return this._infoWindowManager.open(this);
};
/**
* Closes the info window.
*/
BingMapInfoWindow.prototype.close = function () {
var _this = this;
return this._infoWindowManager.close().then(function () {
_this.infoWindowClose.emit(void 0);
});
};
/** @internal */
BingMapInfoWindow.prototype.id = function () {
return this._id;
};
/** @internal */
BingMapInfoWindow.prototype.toString = function () {
return 'BingMapInfoWindow-' + this._id.toString();
};
BingMapInfoWindow._infoWindowOptionsInputs = ['disableAutoPan', 'maxWidth', 'title', 'description'];
__decorate([core_1.ContentChildren(bing_map_info_window_action_1.BingMapInfoWindowAction), __metadata('design:type', core_1.QueryList)], BingMapInfoWindow.prototype, "infoWindowActions", void 0);
BingMapInfoWindow = __decorate([core_1.Component({
selector: 'bing-map-info-window',
inputs: ['latitude', 'longitude', 'disableAutoPan', 'title', 'description', 'height', 'width'],
template: '',
outputs: ['infoWindowClose']
}), __metadata('design:paramtypes', [info_window_manager_1.InfoWindowManager])], BingMapInfoWindow);
return BingMapInfoWindow;
}();
exports.BingMapInfoWindow = BingMapInfoWindow;
return module.exports;
});
System.registerDynamic("angular2-google-maps/directives/bing-map-info-window-action.js", ["@angular/core"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
/**
* BingMapInfoWindowAction renders an action in an info window {@link BingMapInfoWindow}
*
* ### Example
* ```typescript
* import {Component} from '@angular/core';
* import {NG2_BINGMAPS_DIRECTIVES} from 'ng2-bingmaps/core';
*
* @Component({
* selector: 'my-map-cmp',
* directives: [NG2_BINGMAPS_DIRECTIVES],
* styles: [`
* .bing-map-container {
* height: 300px;
* }
* `],
* template: `
* <bing-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
* <bing-map-marker [latitude]="lat" [longitude]="lng" [label]="'M'">
* <bing-map-info-window>
* <bing-map-info-window-action [label]="actionlabel" (actionClicked)="actionClicked()></bing-map-info-window-action>
* </bing-map-info-window>
* </bing-map-marker>
* </bing-map>
* `
* })
* ```
*/
var BingMapInfoWindowAction = function () {
function BingMapInfoWindowAction() {
/**
* Emits an event when the action has been clicked
*/
this.actionClicked = new core_1.EventEmitter();
}
__decorate([core_1.Input(), __metadata('design:type', String)], BingMapInfoWindowAction.prototype, "label", void 0);
__decorate([core_1.Output(), __metadata('design:type', core_1.EventEmitter)], BingMapInfoWindowAction.prototype, "actionClicked", void 0);
BingMapInfoWindowAction = __decorate([core_1.Directive({
selector: 'bing-map-info-window-action'
}), __metadata('design:paramtypes', [])], BingMapInfoWindowAction);
return BingMapInfoWindowAction;
}();
exports.BingMapInfoWindowAction = BingMapInfoWindowAction;
return module.exports;
});
System.registerDynamic('angular2-google-maps/directives.js', ['./directives/bing-map', './directives/bing-map-marker', './directives/bing-map-info-window', './directives/bing-map-info-window-action'], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var bing_map_1 = $__require('./directives/bing-map');
var bing_map_marker_1 = $__require('./directives/bing-map-marker');
var bing_map_info_window_1 = $__require('./directives/bing-map-info-window');
var bing_map_info_window_action_1 = $__require('./directives/bing-map-info-window-action');
var bing_map_2 = $__require('./directives/bing-map');
exports.BingMap = bing_map_2.BingMap;
var bing_map_marker_2 = $__require('./directives/bing-map-marker');
exports.BingMapMarker = bing_map_marker_2.BingMapMarker;
var bing_map_info_window_2 = $__require('./directives/bing-map-info-window');
exports.BingMapInfoWindow = bing_map_info_window_2.BingMapInfoWindow;
exports.NG2_BINGMAPS_DIRECTIVES = [bing_map_1.BingMap, bing_map_marker_1.BingMapMarker, bing_map_info_window_1.BingMapInfoWindow, bing_map_info_window_action_1.BingMapInfoWindowAction];
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/maps-api-loader/noop-maps-api-loader.js", [], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
/**
* When using the NoOpMapsAPILoader, the Google Maps API must be added to the page via a `<script>`
* Tag.
* It's important that the Google Maps API script gets loaded first on the page.
*/
var define,
global = this || self,
GLOBAL = global;
var NoOpMapsAPILoader = function () {
function NoOpMapsAPILoader() {}
NoOpMapsAPILoader.prototype.load = function () {
// todo
throw new Error('todo');
// if (!(<any>window).google || !(<any>window).google.maps) {
// throw new Error(
// 'Bing Maps API not loaded on page. Make sure window.bing.maps is available!');
// }
// return Promise.resolve();
};
;
return NoOpMapsAPILoader;
}();
exports.NoOpMapsAPILoader = NoOpMapsAPILoader;
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/marker-manager.js", ["@angular/core", "rxjs/Observable", "./bing-maps-api-wrapper"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var Observable_1 = $__require("rxjs/Observable");
var bing_maps_api_wrapper_1 = $__require("./bing-maps-api-wrapper");
var MarkerManager = function () {
function MarkerManager(_mapsWrapper, _zone) {
this._mapsWrapper = _mapsWrapper;
this._zone = _zone;
this._markers = new Map();
}
MarkerManager.prototype.deleteMarker = function (marker) {
var _this = this;
var m = this._markers.get(marker);
if (m == null) {
// marker already deleted
return Promise.resolve();
}
return m.then(function (m) {
return _this._zone.run(function () {
m.deleteMarker();
_this._markers.delete(marker);
});
});
};
MarkerManager.prototype.updateMarkerPosition = function (marker) {
return this._markers.get(marker).then(function (m) {
return m.setPosition({ lat: marker.latitude, lng: marker.longitude });
});
};
MarkerManager.prototype.updateTitle = function (marker) {
return this._markers.get(marker).then(function (m) {
return m.setTitle(marker.title);
});
};
MarkerManager.prototype.updateLabel = function (marker) {
return this._markers.get(marker).then(function (m) {
m.setLabel(marker.label);
});
};
MarkerManager.prototype.updateDraggable = function (marker) {
return this._markers.get(marker).then(function (m) {
return m.setDraggable(marker.draggable);
});
};
MarkerManager.prototype.updateIcon = function (marker) {
return this._markers.get(marker).then(function (m) {
return m.setIcon(marker.iconUrl);
});
};
MarkerManager.prototype.addMarker = function (marker) {
var markerPromise = this._mapsWrapper.createMarker({
position: { lat: marker.latitude, lng: marker.longitude },
label: marker.label,
draggable: marker.draggable,
icon: marker.iconUrl
});
this._markers.set(marker, markerPromise);
};
MarkerManager.prototype.getNativeMarker = function (marker) {
return this._markers.get(marker);
};
MarkerManager.prototype.createEventObservable = function (eventName, marker) {
var _this = this;
return Observable_1.Observable.create(function (observer) {
_this._markers.get(marker).then(function (m) {
m.addListener(eventName, function (e) {
return _this._zone.run(function () {
return observer.next(e);
});
});
});
});
};
MarkerManager = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [bing_maps_api_wrapper_1.BingMapsAPIWrapper, core_1.NgZone])], MarkerManager);
return MarkerManager;
}();
exports.MarkerManager = MarkerManager;
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/bing-maps-types.js", [], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var Marker = function () {
function Marker(map, pushpin) {
this.map = map;
this.pushpin = pushpin;
}
Marker.prototype.setPosition = function (latLng) {
this.pushpin.setLocation(new Microsoft.Maps.Location(latLng.lat, latLng.lng));
};
Marker.prototype.deleteMarker = function () {
this.pushpin.setOptions({ visible: false });
};
Marker.prototype.setTitle = function (title) {
console.log('set title');
this.pushpin.setOptions({ text: title });
};
Marker.prototype.setLabel = function (label) {
// title does not exist on the TSD.
this.pushpin.setOptions({ title: label });
};
Marker.prototype.setDraggable = function (draggable) {
this.pushpin.setOptions({ draggable: draggable });
};
Marker.prototype.setIcon = function (icon) {
this.pushpin.setOptions({ icon: icon });
};
Marker.prototype.getLabel = function () {
return null;
};
Marker.prototype.addListener = function (eventType, fn) {
Microsoft.Maps.Events.addHandler(this.pushpin, eventType, function (e) {
fn(e);
});
};
return Marker;
}();
exports.Marker = Marker;
(function (MapTypeId) {
MapTypeId[MapTypeId["aerial"] = 0] = "aerial";
MapTypeId[MapTypeId["auto"] = 1] = "auto";
MapTypeId[MapTypeId["birdseye"] = 2] = "birdseye";
MapTypeId[MapTypeId["collinsBart"] = 3] = "collinsBart";
MapTypeId[MapTypeId["mercator"] = 4] = "mercator";
MapTypeId[MapTypeId["ordnanceSurvey"] = 5] = "ordnanceSurvey";
MapTypeId[MapTypeId["road"] = 6] = "road";
})(exports.MapTypeId || (exports.MapTypeId = {}));
var MapTypeId = exports.MapTypeId;
var InfoWindow = function () {
function InfoWindow(map, infoBox) {
this.map = map;
this.infoBox = infoBox;
}
InfoWindow.prototype.close = function () {
this.infoBox.setMap(null);
this.infoBox.setOptions({ visible: false });
};
;
InfoWindow.prototype.getPosition = function () {
return {
lat: this.infoBox.getLocation().latitude,
lng: this.infoBox.getLocation().longitude
};
};
;
InfoWindow.prototype.open = function () {
// when using custom HTML, you have to do setMap.
this.infoBox.setMap(this.map);
this.infoBox.setOptions({
visible: true
});
};
;
InfoWindow.prototype.setOptions = function (options) {
this.infoBox.setOptions({
title: options.title,
description: options.title
});
};
;
InfoWindow.prototype.setPosition = function (position) {
this.infoBox.setLocation(new Microsoft.Maps.Location(position.lat, position.lng));
};
;
return InfoWindow;
}();
exports.InfoWindow = InfoWindow;
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/bing-maps-api-wrapper.js", ["@angular/core", "rxjs/Observable", "./maps-api-loader/maps-api-loader", "./bing-maps-types", "./maps-api-loader/lazy-maps-api-loader"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var Observable_1 = $__require("rxjs/Observable");
var maps_api_loader_1 = $__require("./maps-api-loader/maps-api-loader");
var mapTypes = $__require("./bing-maps-types");
var lazy_maps_api_loader_1 = $__require("./maps-api-loader/lazy-maps-api-loader");
/**
* Wrapper class that handles the communication with the Bing Maps Javascript
* API v8
*/
var BingMapsAPIWrapper = function () {
function BingMapsAPIWrapper(_loader, _zone, _config) {
var _this = this;
this._loader = _loader;
this._zone = _zone;
this._config = _config;
this.infoBox = null;
this._mapResolver = null;
this.nativeMap = new Promise(function (resolve) {
_this._mapResolver = resolve;
});
}
BingMapsAPIWrapper.prototype.createMap = function (el, mapOptions) {
var _this = this;
return this._loader.load().then(function () {
// todo other options
var map = new Microsoft.Maps.Map(el, {
credentials: _this._config.apiKey,
center: new Microsoft.Maps.Location(mapOptions.center.lat, mapOptions.center.lng),
zoom: mapOptions.zoom,
mapTypeId: mapOptions.mapTypeId
});
_this._mapResolver(map);
/**
* Create one infobox which is reused.
*/
_this.infoBox = new Promise(function (resolve) {
_this._infoBoxResolver = resolve;
});
var infoBox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), {});
_this._infoBoxResolver(infoBox);
return map;
});
};
BingMapsAPIWrapper.prototype.setMapOptions = function (options) {
this.nativeMap.then(function (m) {
m.setOptions({
center: new Microsoft.Maps.Location(options.center.lat, options.center.lng),
zoom: options.zoom,
mapTypeId: options.mapTypeId
});
// todo other options
});
};
/**
* Creates a Bing map marker with the map context
*/
BingMapsAPIWrapper.prototype.createMarker = function (options) {
if (options === void 0) {
options = {};
}
return this.nativeMap.then(function (map) {
var loc = new Microsoft.Maps.Location(options.position.lat, options.position.lng);
var pushpin = new Microsoft.Maps.Pushpin(loc);
map.entities.push(pushpin);
return new mapTypes.Marker(map, pushpin);
});
};
BingMapsAPIWrapper.prototype.getInfoWindow = function (options) {
var _this = this;
return this.nativeMap.then(function (map) {
return _this.infoBox.then(function (infoBox) {
if (typeof options === "undefined" || options == null) {
return new mapTypes.InfoWindow(map, infoBox);
} else {
var nativeOptions = {
visible: false,
title: options.title,
location: new Microsoft.Maps.Location(options.position.lat, options.position.lng),
description: options.description,
actions: options.actions
};
if (options.height > 0) {
nativeOptions.maxHeight = options.height;
}
if (options.width > 0) {
nativeOptions.maxWidth = options.width;
}
infoBox.setOptions(nativeOptions);
return new mapTypes.InfoWindow(map, infoBox);
}
});
});
};
BingMapsAPIWrapper.prototype.subscribeToMapEvent = function (eventName) {
var _this = this;
return Observable_1.Observable.create(function (observer) {
_this.nativeMap.then(function (m) {
Microsoft.Maps.Events.addHandler(m, eventName, function (e) {
_this._zone.run(function () {
return observer.next(e);
});
});
});
});
};
BingMapsAPIWrapper.prototype.setCenter = function (latLng) {
return this.nativeMap.then(function (map) {
return map.setView({
center: new Microsoft.Maps.Location(latLng.lat, latLng.lng)
});
});
};
BingMapsAPIWrapper.prototype.getZoom = function () {
return this.nativeMap.then(function (map) {
return map.getZoom();
});
};
BingMapsAPIWrapper.prototype.setZoom = function (zoom) {
return this.nativeMap.then(function (map) {
return map.setView({ zoom: zoom });
});
};
BingMapsAPIWrapper.prototype.getCenter = function () {
return this.nativeMap.then(function (map) {
var center = map.getCenter();
return {
lat: center.latitude,
lng: center.longitude
};
});
};
/**
* Triggers the given event name on the map instance.
*/
BingMapsAPIWrapper.prototype.triggerMapEvent = function (eventName) {
return this.nativeMap.then(function (m) {
return Microsoft.Maps.Events.invoke(m, eventName, null);
});
};
BingMapsAPIWrapper = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [maps_api_loader_1.MapsAPILoader, core_1.NgZone, lazy_maps_api_loader_1.LazyMapsAPILoaderConfig])], BingMapsAPIWrapper);
return BingMapsAPIWrapper;
}();
exports.BingMapsAPIWrapper = BingMapsAPIWrapper;
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/info-window-manager.js", ["@angular/core", "./bing-maps-api-wrapper"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var bing_maps_api_wrapper_1 = $__require("./bing-maps-api-wrapper");
var InfoWindowManager = function () {
function InfoWindowManager(_mapsWrapper, _zone) {
this._mapsWrapper = _mapsWrapper;
this._zone = _zone;
}
InfoWindowManager.prototype.setPosition = function (infoWindow) {
return this._mapsWrapper.getInfoWindow().then(function (i) {
return i.setPosition({
lat: infoWindow.latitude,
lng: infoWindow.longitude
});
});
};
// open(infoWindow: BingMapInfoWindow): Promise<void> {
// return this._infoWindows.get(infoWindow).then((w) => {
// w.open();
// });
// }
InfoWindowManager.prototype.close = function () {
return this._mapsWrapper.getInfoWindow().then(function (w) {
return w.close();
});
};
InfoWindowManager.prototype.setOptions = function (options) {
return this._mapsWrapper.getInfoWindow().then(function (w) {
return w.setOptions(options);
});
};
InfoWindowManager.prototype.open = function (infoWindow) {
var options = {
title: infoWindow.title,
description: infoWindow.description,
height: +infoWindow.height,
width: +infoWindow.width
};
if (typeof infoWindow.latitude === 'number' && typeof infoWindow.longitude === 'number') {
options.position = { lat: infoWindow.latitude, lng: infoWindow.longitude };
}
if (typeof infoWindow.infoWindowActions !== 'undefined' && infoWindow.infoWindowActions.length > 0) {
options.actions = [];
infoWindow.infoWindowActions.forEach(function (infoWindowAction) {
options.actions.push({
label: infoWindowAction.label,
eventHandler: function () {
infoWindowAction.actionClicked.emit(null);
}
});
});
}
return this._mapsWrapper.getInfoWindow(options).then(function (i) {
i.open();
});
};
InfoWindowManager = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [bing_maps_api_wrapper_1.BingMapsAPIWrapper, core_1.NgZone])], InfoWindowManager);
return InfoWindowManager;
}();
exports.InfoWindowManager = InfoWindowManager;
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/maps-api-loader/maps-api-loader.js", ["@angular/core"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = $__require("@angular/core");
var MapsAPILoader = function () {
function MapsAPILoader() {}
MapsAPILoader = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [])], MapsAPILoader);
return MapsAPILoader;
}();
exports.MapsAPILoader = MapsAPILoader;
return module.exports;
});
System.registerDynamic("angular2-google-maps/services/maps-api-loader/lazy-maps-api-loader.js", ["@angular/core", "./maps-api-loader"], true, function ($__require, exports, module) {
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
"use strict";
var define,
global = this || self,
GLOBAL = global;
var __extends = this && this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = this && this.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = this && this.__param || function (paramIndex, decorator) {
return function (target