map-alliance/src/main.ts

62 lines
2.1 KiB
TypeScript
Raw Normal View History

2019-07-02 08:11:23 -04:00
import 'hammerjs';
2019-08-24 11:26:30 -04:00
import {enableProdMode} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
2019-07-02 08:11:23 -04:00
2019-08-24 11:26:30 -04:00
import {AppModule} from './app/app.module';
import {environment} from './environments/environment';
2019-07-02 08:11:23 -04:00
if (environment.production) {
2019-08-24 11:26:30 -04:00
enableProdMode();
2019-07-02 08:11:23 -04:00
}
platformBrowserDynamic().bootstrapModule(AppModule)
2019-08-24 11:26:30 -04:00
.catch(err => console.error(err));
2019-08-24 12:45:40 -04:00
// leaflet ===========================================
2019-08-24 11:26:30 -04:00
declare const L;
2019-08-24 12:45:40 -04:00
// Touch support
2019-08-24 11:26:30 -04:00
L.Map.mergeOptions({touchExtend: true});
L.Map.TouchExtend = L.Handler.extend({
initialize: function (map) {
this._map = map;
this._container = map._container;
this._pane = map._panes.overlayPane;
},
addHooks: function () {
L.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);
L.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);
L.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);
},
removeHooks: function () {
L.DomEvent.off(this._container, 'touchstart', this._onTouchStart);
L.DomEvent.off(this._container, 'touchend', this._onTouchEnd);
L.DomEvent.off(this._container, 'touchmove', this._onTouchMove);
},
2019-08-24 12:02:43 -04:00
_eventWrapper: function(e) {
let containerPoint = this._map.mouseEventToContainerPoint(e);
let layerPoint = this._map.containerPointToLayerPoint(containerPoint);
let latlng = this._map.layerPointToLatLng(layerPoint);
return {
latlng: latlng,
layerPoint: layerPoint,
containerPoint: containerPoint,
originalEvent: e
}
},
2019-08-24 11:26:30 -04:00
_onTouchStart: function (e) {
if (!this._map._loaded) return;
2019-08-24 12:02:43 -04:00
this._map.fire('touchstart', this._eventWrapper(e));
2019-08-24 11:26:30 -04:00
},
_onTouchEnd: function (e) {
if (!this._map._loaded) return;
2019-08-24 12:02:43 -04:00
this._map.fire('touchend', this._eventWrapper(e));
2019-08-24 11:26:30 -04:00
},
_onTouchMove: function(e) {
if(!this._map._loaded) return;
2019-08-24 12:02:43 -04:00
this._map.fire('touchmove', this._eventWrapper(e));
2019-08-24 11:26:30 -04:00
}
});
L.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);