diff --git a/angular.json b/angular.json
index e346a4f..bd5deca 100644
--- a/angular.json
+++ b/angular.json
@@ -11,8 +11,11 @@
"schematics": {},
"architect": {
"build": {
- "builder": "@angular-devkit/build-angular:browser",
+ "builder": "@angular-builders/custom-webpack:browser",
"options": {
+ "customWebpackConfig": {
+ "path": "./custom-webpack.config.js"
+ },
"aot": true,
"outputPath": "dist/farmmaps-lib-app",
"index": "src/index.html",
@@ -85,7 +88,7 @@
}
},
"serve": {
- "builder": "@angular-devkit/build-angular:dev-server",
+ "builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "farmmaps-lib-app:build"
},
diff --git a/custom-webpack.config.js b/custom-webpack.config.js
new file mode 100644
index 0000000..70173ee
--- /dev/null
+++ b/custom-webpack.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ node: {
+ // Resolve node module use of fs
+ fs: "empty",
+ Buffer: false,
+ http: "empty",
+ https: "empty",
+ zlib: "empty"
+ }
+ };
\ No newline at end of file
diff --git a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts
index 2bb45fc..1428028 100644
--- a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts
+++ b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges } from '@angular/core';
+import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges ,Host} from '@angular/core';
import { MapComponent } from 'ngx-openlayers';
import Overlay from 'ol/Overlay';
import { fromLonLat, toLonLat } from 'ol/proj';
@@ -23,9 +23,10 @@ export class GpsLocation implements OnInit,OnChanges{
public path: string = "";
public rotate: string = "";
private resolution: number = 0;
+ initialized:boolean = false;
@ViewChild('location', { static: true }) locationElement: ElementRef;
- constructor(private map: MapComponent) {
+ constructor(@Host() private map: MapComponent) {
}
@@ -54,12 +55,13 @@ export class GpsLocation implements OnInit,OnChanges{
this.resolution = evt.target.get('resolution');
this.recalcLocationTolerance();
});
+ this.initialized = true;
}
ngOnChanges(changes: SimpleChanges) {
if (changes.position && this.instance) {
var p = changes.position.currentValue as Position;
- if(p) {
+ if(p && this.initialized) {
this.instance.setPosition(fromLonLat([p.coords.longitude, p.coords.latitude]));
this.locationTolerance = p.coords.accuracy;
this.recalcLocationTolerance();
diff --git a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts
index 29266b1..bed4b90 100644
--- a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts
+++ b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts
@@ -99,17 +99,12 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
var l = (data && data.layers && data.layers.length > 0) ? data.layers[0] : null;
if (l && l.rendering && l.rendering.renderoutputType == "Tiles") {
var rt = l.rendering as IRenderoutputTiles;
- let source = new XYZ({ maxZoom: rt.maxzoom, minZoom: rt.minzoom, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${Date.parse(item.updated)}` });
+ let source = new XYZ({crossOrigin: 'use-credentials', maxZoom: rt.maxzoom, minZoom: rt.minzoom, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${Date.parse(item.updated)}` });
layer = new Tile({ source: source });
}
if (l && l.rendering && l.rendering.renderoutputType == "Image") {
- var ri = l.rendering as IRenderoutputImage;
- let projection = new Projection({
- code: 'image',
- units: 'pixels',
- extent: ri.extent
- });
- let source = new ImageStatic({ imageExtent: ri.extent, projection: projection, url: `${this._apiEndPoint}/api/v1/items/${item.code}/mapimage/${layerIndex}?v=${Date.parse(item.updated)}` });
+ var ri = l.rendering as IRenderoutputImage;
+ let source = new ImageStatic({ imageExtent: ri.extent, crossOrigin: 'use-credentials',projection: "EPSG:3857", url: `${this._apiEndPoint}/api/v1/items/${item.code}/mapimage/${layerIndex}?v=${Date.parse(item.updated)}` });
layer = new Image({ source: source });
}
return layer;
diff --git a/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts b/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts
index 090e5ea..7c11286 100644
--- a/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts
+++ b/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit,Input,Host } from '@angular/core';
import { MapComponent } from 'ngx-openlayers';
import OLCesium from 'ol-cesium';
+declare var olcs: any;
@Component({
selector: 'fm-map-switch2d3d',
@@ -21,20 +22,35 @@ export class Switch2D3DComponent {
@Input() enable:boolean;
public label: string = "3D";
private ol3d: OLCesium;
+ private synchronizers:any[];
constructor(@Host() private map: MapComponent) {
}
- ngOnInit() {
- this.ol3d = new OLCesium({ map: this.map.instance }); // ol2dMap is the ol.Map instance
+ ngOnInit() {
+ this.ol3d = new OLCesium({ map: this.map.instance,createSynchronizers: (map,scene) => {
+ this.synchronizers = [
+ new olcs.RasterSynchronizer(map,scene),
+ new olcs.VectorSynchronizer(map,scene)
+ ];
+ return this.synchronizers;
+ },stopOpenLayersEventsPropagation:true});
+ }
+
+ synchronize() {
+ this.synchronizers.forEach((synchronizer) => {
+ synchronizer.synchronize();
+ });
}
handleClick(event) {
- this.enable = !this.enable;
- if (this.enable)
- this.ol3d.setEnabled(this.enable);
- this.label = this.enable?"2D":"3D";
+ this.enable = !this.enable;
+ if(this.enable) {
+ this.synchronize();
+ }
+ this.ol3d.setEnabled(this.enable);
+ this.label = this.enable?"2D":"3D";
}
}
diff --git a/projects/common-map/src/fm-map/components/map/map.component.html b/projects/common-map/src/fm-map/components/map/map.component.html
index 8b807a6..45854c4 100644
--- a/projects/common-map/src/fm-map/components/map/map.component.html
+++ b/projects/common-map/src/fm-map/components/map/map.component.html
@@ -37,7 +37,7 @@