@sswroom/sswr 1.6.21 → 1.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog +10 -0
- package/cesium.d.ts +12 -5
- package/cesium.js +221 -21
- package/data.js +1 -1
- package/dummy/olayer2.d.ts +1 -1
- package/leaflet.d.ts +10 -4
- package/leaflet.js +258 -16
- package/map.d.ts +39 -29
- package/olayer2.d.ts +10 -4
- package/olayer2.js +82 -3
- package/package.json +1 -1
package/Changelog
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
1.6.22
|
|
2
|
+
-Enhance map.MapControl Marker
|
|
3
|
+
-Added map.MapControl.layerMoveMarker
|
|
4
|
+
-Added map.MapControl.markerUpdateIcon
|
|
5
|
+
-Added map.MapControl.markerShowPopup
|
|
6
|
+
-Added map.MapControl.hidePopup
|
|
7
|
+
-Added map.MapControl.sizeUpdated
|
|
8
|
+
-Added cesium.parseColor
|
|
9
|
+
-Enhance cesium and leaflet map
|
|
10
|
+
|
|
1
11
|
1.6.21
|
|
2
12
|
-Added data.dataURI2Blob
|
|
3
13
|
-Added EasyPrint.toSVG
|
package/cesium.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as geometry from "./geometry";
|
|
|
3
3
|
import * as kml from "./kml";
|
|
4
4
|
import * as map from "./map";
|
|
5
5
|
import * as math from "./math";
|
|
6
|
+
import * as web from "./web";
|
|
6
7
|
|
|
7
8
|
declare class KMLFeatureOptions
|
|
8
9
|
{
|
|
@@ -18,10 +19,12 @@ export function fromCartesian3Array(viewer: Viewer, arr: Cartesian3[]): object[]
|
|
|
18
19
|
export function fromPolygonGraphics(viewer: Viewer, pg: PolygonGraphics): geometry.Polygon;
|
|
19
20
|
export function createFromKML(feature: kml.Feature | kml.KMLFile, options: KMLFeatureOptions): any;
|
|
20
21
|
export function createFromGeometry(geom: geometry.Vector2D, options: map.GeometryOptions)
|
|
21
|
-
|
|
22
|
+
export function parseColor(c: string): web.Color;
|
|
22
23
|
export class CesiumMap extends map.MapControl
|
|
23
24
|
{
|
|
24
25
|
constructor(divId: string);
|
|
26
|
+
getDiv(): HTMLDivElement;
|
|
27
|
+
sizeUpdated(): void;
|
|
25
28
|
createLayer(layer: map.LayerInfo, options?: map.LayerOptions): any;
|
|
26
29
|
createMarkerLayer(name: string, options?: map.LayerOptions): any;
|
|
27
30
|
createGeometryLayer(name: string, options?: map.LayerOptions): any;
|
|
@@ -40,11 +43,15 @@ export class CesiumMap extends map.MapControl
|
|
|
40
43
|
map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
41
44
|
scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
42
45
|
|
|
43
|
-
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions):
|
|
44
|
-
layerAddMarker(markerLayer: any, marker:
|
|
45
|
-
layerRemoveMarker(markerLayer: any, marker:
|
|
46
|
+
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions): map.MarkerInfo;
|
|
47
|
+
layerAddMarker(markerLayer: any, marker: map.MarkerInfo): void;
|
|
48
|
+
layerRemoveMarker(markerLayer: any, marker: map.MarkerInfo): void;
|
|
46
49
|
layerClearMarkers(markerLayer: any): void;
|
|
47
|
-
|
|
50
|
+
layerMoveMarker(markerLayer: any, marker: MarkerInfo, mapPos: math.Coord2D): MarkerInfo;
|
|
51
|
+
markerUpdateIcon(markerLayer: any, marker: MarkerInfo, url: string): MarkerInfo;
|
|
52
|
+
markerIsOver(marker: map.MarkerInfo, scnPos: math.Coord2D): boolean;
|
|
53
|
+
markerShowPopup(marker: MarkerInfo, content: string, w?: number, h?: number): void;
|
|
54
|
+
hidePopup();
|
|
48
55
|
|
|
49
56
|
createGeometry(geom: geometry.Vector2D, options: map.GeometryOptions): any;
|
|
50
57
|
layerAddGeometry(geometryLayer: any, geom: any): void;
|
package/cesium.js
CHANGED
|
@@ -4,7 +4,14 @@ import * as kml from "./kml.js";
|
|
|
4
4
|
import * as map from "./map.js";
|
|
5
5
|
import * as math from "./math.js";
|
|
6
6
|
import * as text from "./text.js";
|
|
7
|
+
import * as web from "./web.js";
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @param {{ scene: { globe: { ellipsoid: any; }; }; camera: { pickEllipsoid: (arg0: any, arg1: any) => any; }; }} viewer
|
|
11
|
+
* @param {number} x
|
|
12
|
+
* @param {number} y
|
|
13
|
+
* @param {{ cartesianToCartographic: (arg0: any) => any; } | null} ellipsoid
|
|
14
|
+
*/
|
|
8
15
|
export function screenToLatLon(viewer, x, y, ellipsoid)
|
|
9
16
|
{
|
|
10
17
|
let pos = new Cesium.Cartesian2(x, y);
|
|
@@ -258,6 +265,10 @@ export function createFromKML(feature, options)
|
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
267
|
|
|
268
|
+
/**
|
|
269
|
+
* @param {geometry.Vector2D} geom
|
|
270
|
+
* @param {map.GeometryOptions} options
|
|
271
|
+
*/
|
|
261
272
|
export function createFromGeometry(geom, options)
|
|
262
273
|
{
|
|
263
274
|
if (geom instanceof geometry.Point)
|
|
@@ -278,12 +289,40 @@ export function createFromGeometry(geom, options)
|
|
|
278
289
|
position: Cesium.Cartesian3.fromDegrees(geom.coordinates[0], geom.coordinates[1]),
|
|
279
290
|
billboard: new Cesium.BillboardGraphics(opt)});
|
|
280
291
|
}
|
|
292
|
+
else if (geom instanceof geometry.LinearRing)
|
|
293
|
+
{
|
|
294
|
+
let opt = {};
|
|
295
|
+
opt.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
296
|
+
opt.height = 0;
|
|
297
|
+
if (options.lineColor)
|
|
298
|
+
{
|
|
299
|
+
let c = parseColor(options.lineColor);
|
|
300
|
+
opt.outlineColor = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
301
|
+
opt.outline = true;
|
|
302
|
+
}
|
|
303
|
+
if (options.lineWidth)
|
|
304
|
+
{
|
|
305
|
+
opt.outlineWidth = options.lineWidth;
|
|
306
|
+
opt.outline = true;
|
|
307
|
+
}
|
|
308
|
+
if (options.fillColor)
|
|
309
|
+
{
|
|
310
|
+
let c = parseColor(options.fillColor);
|
|
311
|
+
if (options.fillOpacity)
|
|
312
|
+
{
|
|
313
|
+
c.a = options.fillOpacity;
|
|
314
|
+
}
|
|
315
|
+
opt.material = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
316
|
+
}
|
|
317
|
+
opt.hierarchy = {positions: toCartesian3Arr(geom.coordinates), holes: []};
|
|
318
|
+
return new Cesium.Entity({polygon: new Cesium.PolygonGraphics(opt)});
|
|
319
|
+
}
|
|
281
320
|
else if (geom instanceof geometry.LineString)
|
|
282
321
|
{
|
|
283
322
|
let opt = {};
|
|
284
323
|
if (options.lineColor)
|
|
285
324
|
{
|
|
286
|
-
let c =
|
|
325
|
+
let c = parseColor(options.lineColor);
|
|
287
326
|
opt.material = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
288
327
|
}
|
|
289
328
|
if (options.lineWidth)
|
|
@@ -298,7 +337,7 @@ export function createFromGeometry(geom, options)
|
|
|
298
337
|
opt.height = 0;
|
|
299
338
|
if (options.lineColor)
|
|
300
339
|
{
|
|
301
|
-
let c =
|
|
340
|
+
let c = parseColor(options.lineColor);
|
|
302
341
|
opt.outlineColor = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
303
342
|
opt.outline = true;
|
|
304
343
|
}
|
|
@@ -309,7 +348,11 @@ export function createFromGeometry(geom, options)
|
|
|
309
348
|
}
|
|
310
349
|
if (options.fillColor)
|
|
311
350
|
{
|
|
312
|
-
let c =
|
|
351
|
+
let c = parseColor(options.fillColor);
|
|
352
|
+
if (options.fillOpacity)
|
|
353
|
+
{
|
|
354
|
+
c.a = options.fillOpacity;
|
|
355
|
+
}
|
|
313
356
|
opt.material = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
314
357
|
}
|
|
315
358
|
opt.hierarchy = {positions: toCartesian3Arr(geom.geometries[0].coordinates), holes: []};
|
|
@@ -331,7 +374,7 @@ export function createFromGeometry(geom, options)
|
|
|
331
374
|
let opt = {};
|
|
332
375
|
if (options.lineColor)
|
|
333
376
|
{
|
|
334
|
-
let c =
|
|
377
|
+
let c = parseColor(options.lineColor);
|
|
335
378
|
opt.outlineColor = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
336
379
|
opt.outline = true;
|
|
337
380
|
}
|
|
@@ -342,7 +385,11 @@ export function createFromGeometry(geom, options)
|
|
|
342
385
|
}
|
|
343
386
|
if (options.fillColor)
|
|
344
387
|
{
|
|
345
|
-
let c =
|
|
388
|
+
let c = parseColor(options.fillColor);
|
|
389
|
+
if (options.fillOpacity)
|
|
390
|
+
{
|
|
391
|
+
c.a = options.fillOpacity;
|
|
392
|
+
}
|
|
346
393
|
opt.material = new Cesium.Color(c.r, c.g, c.b, c.a);
|
|
347
394
|
}
|
|
348
395
|
console.log("MultiPolygon not supported", geom);
|
|
@@ -355,6 +402,19 @@ export function createFromGeometry(geom, options)
|
|
|
355
402
|
}
|
|
356
403
|
}
|
|
357
404
|
|
|
405
|
+
/**
|
|
406
|
+
* @param {string} c
|
|
407
|
+
*/
|
|
408
|
+
export function parseColor(c)
|
|
409
|
+
{
|
|
410
|
+
let col = kml.toColor(c);
|
|
411
|
+
if (col == null)
|
|
412
|
+
{
|
|
413
|
+
col = web.parseCSSColor(c);
|
|
414
|
+
}
|
|
415
|
+
return col;
|
|
416
|
+
}
|
|
417
|
+
|
|
358
418
|
/*export function createPolygon(viewer, lats, lons, height)
|
|
359
419
|
{
|
|
360
420
|
if (lats.length != lons.length)
|
|
@@ -386,6 +446,7 @@ export class CesiumMap extends map.MapControl
|
|
|
386
446
|
constructor(divId)
|
|
387
447
|
{
|
|
388
448
|
super();
|
|
449
|
+
this.mouseMove = null;
|
|
389
450
|
this.viewer = new Cesium.Viewer(divId, {
|
|
390
451
|
timeline:false,
|
|
391
452
|
animation:false,
|
|
@@ -395,8 +456,29 @@ export class CesiumMap extends map.MapControl
|
|
|
395
456
|
// url: "https://tile.openstreetmap.org/"
|
|
396
457
|
// }))}
|
|
397
458
|
});
|
|
459
|
+
this.viewer.screenSpaceEventHandler.setInputAction((movement) => {
|
|
460
|
+
let pos = movement.startPosition;
|
|
461
|
+
let container = this.viewer.container;
|
|
462
|
+
if (pos.x >= 0 && pos.y >= 0 && pos.x < container.offsetWidth && pos.y < container.offsetHeight)
|
|
463
|
+
{
|
|
464
|
+
if (this.mouseMove)
|
|
465
|
+
{
|
|
466
|
+
this.mouseMove(this.scn2MapPos(new math.Coord2D(pos.x, pos.y)));
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
398
470
|
};
|
|
399
471
|
|
|
472
|
+
getDiv()
|
|
473
|
+
{
|
|
474
|
+
return this.viewer.container;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
sizeUpdated()
|
|
478
|
+
{
|
|
479
|
+
|
|
480
|
+
}
|
|
481
|
+
|
|
400
482
|
createLayer(layer, options)
|
|
401
483
|
{
|
|
402
484
|
if (layer.type == map.WebMapType.OSMTile)
|
|
@@ -411,8 +493,16 @@ export class CesiumMap extends map.MapControl
|
|
|
411
493
|
}
|
|
412
494
|
}
|
|
413
495
|
|
|
414
|
-
|
|
415
|
-
|
|
496
|
+
createMarkerLayer(name, options)
|
|
497
|
+
{
|
|
498
|
+
return [];
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
createGeometryLayer(name, options)
|
|
502
|
+
{
|
|
503
|
+
return [];
|
|
504
|
+
}
|
|
505
|
+
|
|
416
506
|
addLayer(layer)
|
|
417
507
|
{
|
|
418
508
|
if (layer instanceof Cesium.ImageryLayer)
|
|
@@ -481,22 +571,132 @@ export class CesiumMap extends map.MapControl
|
|
|
481
571
|
this.viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees(center.x, center.y, xScale), duration:0});
|
|
482
572
|
}
|
|
483
573
|
|
|
484
|
-
/* handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
574
|
+
/* handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void;*/
|
|
575
|
+
/**
|
|
576
|
+
* @param {(mapPos: math.Coord2D)=>void} moveFunc
|
|
577
|
+
*/
|
|
578
|
+
handleMouseMove(moveFunc)
|
|
579
|
+
{
|
|
580
|
+
this.mouseMove = moveFunc;
|
|
581
|
+
}
|
|
582
|
+
/* handlePosChange(posFunc: (mapPos: math.Coord2D)=>void): void;*/
|
|
583
|
+
/**
|
|
584
|
+
* @param {math.Coord2D} mapPos
|
|
585
|
+
*/
|
|
586
|
+
map2ScnPos(mapPos)
|
|
587
|
+
{
|
|
588
|
+
let pos = Cesium.SceneTransforms.worldToDrawingBufferCoordinates(this.viewer.scene, Cesium.Cartesian3.fromDegrees(mapPos.x, mapPos.y));
|
|
589
|
+
if (pos)
|
|
590
|
+
{
|
|
591
|
+
return new math.Coord2D(pos.x, pos.y);
|
|
592
|
+
}
|
|
593
|
+
else
|
|
594
|
+
{
|
|
595
|
+
return new math.Coord2D(0, 0);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* @param {math.Coord2D} scnPos
|
|
601
|
+
*/
|
|
602
|
+
scn2MapPos(scnPos)
|
|
603
|
+
{
|
|
604
|
+
return screenToLatLon(this.viewer, scnPos.x, scnPos.y, null);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
createMarker(mapPos, imgURL, imgWidth, imgHeight, options)
|
|
608
|
+
{
|
|
609
|
+
return new Cesium.Entity({position: Cesium.Cartesian3.fromDegrees(mapPos.x, mapPos.y), billboard: {image: imgURL, width: imgWidth, height: imgHeight}});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
layerAddMarker(markerLayer, marker)
|
|
613
|
+
{
|
|
614
|
+
markerLayer.push(marker);
|
|
615
|
+
this.viewer.entities.add(marker);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
layerRemoveMarker(markerLayer, marker)
|
|
619
|
+
{
|
|
620
|
+
markerLayer.remove(marker);
|
|
621
|
+
this.viewer.entities.remove(marker);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
layerClearMarkers(markerLayer)
|
|
625
|
+
{
|
|
626
|
+
let geom;
|
|
627
|
+
while (geom = markerLayer.pop())
|
|
628
|
+
{
|
|
629
|
+
this.viewer.entities.remove(geom);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
layerMoveMarker(markerLayer, marker, mapPos)
|
|
634
|
+
{
|
|
635
|
+
marker.position = Cesium.Cartesian3.fromDegrees(mapPos.x, mapPos.y);
|
|
636
|
+
return marker;
|
|
637
|
+
}
|
|
489
638
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
639
|
+
markerUpdateIcon(markerLayer, marker, url)
|
|
640
|
+
{
|
|
641
|
+
marker.billboard.image = url;
|
|
642
|
+
return marker;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
markerIsOver(marker, scnPos)
|
|
646
|
+
{
|
|
647
|
+
let latlng = marker.position.getValue();
|
|
648
|
+
let sz = [marker.billboard.width, marker.billboard.height];
|
|
649
|
+
let iconPos = Cesium.SceneTransforms.worldToDrawingBufferCoordinates(this.viewer.scene, latlng);
|
|
650
|
+
if (sz == null)
|
|
651
|
+
return false;
|
|
652
|
+
if ((scnPos.x < iconPos.x - sz[0] * 0.5) || (scnPos.y < iconPos.y - sz[1] * 0.5))
|
|
653
|
+
return false;
|
|
654
|
+
if ((iconPos.x + sz[0] * 0.5 <= scnPos.x) || (iconPos.y + sz[1] * 0.5 <= scnPos.y))
|
|
655
|
+
return false;
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
markerShowPopup(marker, content, w, h)
|
|
660
|
+
{
|
|
661
|
+
marker.description = {getValue: ()=>{return content;}};
|
|
662
|
+
this.viewer.selectedEntity = marker;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
hidePopup()
|
|
666
|
+
{
|
|
667
|
+
this.viewer.selectedEntity = null;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* @param {geometry.Vector2D} geom
|
|
672
|
+
* @param {map.GeometryOptions} options
|
|
673
|
+
*/
|
|
674
|
+
createGeometry(geom, options)
|
|
675
|
+
{
|
|
676
|
+
return createFromGeometry(geom, options);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
layerAddGeometry(geometryLayer, geom)
|
|
680
|
+
{
|
|
681
|
+
geometryLayer.push(geom);
|
|
682
|
+
this.viewer.entities.add(geom);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
layerRemoveGeometry(geometryLayer, geom)
|
|
686
|
+
{
|
|
687
|
+
geometryLayer.remove(geom);
|
|
688
|
+
this.viewer.entities.remove(geom);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
layerClearGeometries(geometryLayer)
|
|
692
|
+
{
|
|
693
|
+
let geom;
|
|
694
|
+
while (geom = geometryLayer.pop())
|
|
695
|
+
{
|
|
696
|
+
this.viewer.entities.remove(geom);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
495
699
|
|
|
496
|
-
createGeometry(geom: geometry.Vector2D, options: GeometryOptions): any;
|
|
497
|
-
layerAddGeometry(geometryLayer: any, geom: any): void;
|
|
498
|
-
layerRemoveGeometry(geometryLayer: any, geom: any): void;
|
|
499
|
-
layerClearGeometries(geometryLayer: any): void;*/
|
|
500
700
|
getViewer()
|
|
501
701
|
{
|
|
502
702
|
return this.viewer;
|
package/data.js
CHANGED
package/dummy/olayer2.d.ts
CHANGED
|
@@ -2095,7 +2095,7 @@ export class Popup
|
|
|
2095
2095
|
* @param closeBox Whether to display a close box inside the popup.
|
|
2096
2096
|
* @param closeBoxCallback Function to be called on closeBox click.
|
|
2097
2097
|
*/
|
|
2098
|
-
constructor(id: string, lonlat: LonLat, contentSize: Size|null, contentHTML: string, closeBox: boolean, closeBoxCallback
|
|
2098
|
+
constructor(id: string, lonlat: LonLat, contentSize: Size|null, contentHTML: string, closeBox: boolean, closeBoxCallback?: Function);
|
|
2099
2099
|
/**
|
|
2100
2100
|
* Auto size the popup so that it precisely fits its contents (as determined by this.contentDiv.innerHTML). Popup size will, of course, be limited by the available space on the current map
|
|
2101
2101
|
*/
|
package/leaflet.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export class KMLNetworkLink
|
|
|
40
40
|
export class LeafletMap extends map.MapControl
|
|
41
41
|
{
|
|
42
42
|
constructor(divId: string);
|
|
43
|
+
getDiv(): HTMLDivElement;
|
|
44
|
+
sizeUpdated(): void;
|
|
43
45
|
createLayer(layer: map.LayerInfo, options?: map.LayerOptions): any;
|
|
44
46
|
createMarkerLayer(name: string, options?: map.LayerOptions): any;
|
|
45
47
|
createGeometryLayer(name: string, options?: map.LayerOptions): any;
|
|
@@ -58,11 +60,15 @@ export class LeafletMap extends map.MapControl
|
|
|
58
60
|
map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
59
61
|
scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
60
62
|
|
|
61
|
-
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions):
|
|
62
|
-
layerAddMarker(markerLayer: any, marker:
|
|
63
|
-
layerRemoveMarker(markerLayer: any, marker:
|
|
63
|
+
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions): map.MarkerInfo;
|
|
64
|
+
layerAddMarker(markerLayer: any, marker: map.MarkerInfo): void;
|
|
65
|
+
layerRemoveMarker(markerLayer: any, marker: map.MarkerInfo): void;
|
|
64
66
|
layerClearMarkers(markerLayer: any): void;
|
|
65
|
-
|
|
67
|
+
layerMoveMarker(markerLayer: any, marker: MarkerInfo, mapPos: math.Coord2D): MarkerInfo;
|
|
68
|
+
markerUpdateIcon(markerLayer: any, marker: MarkerInfo, url: string): MarkerInfo;
|
|
69
|
+
markerIsOver(marker: map.MarkerInfo, scnPos: math.Coord2D): boolean;
|
|
70
|
+
markerShowPopup(marker: MarkerInfo, content: string, w?: number, h?: number): void;
|
|
71
|
+
hidePopup();
|
|
66
72
|
|
|
67
73
|
createGeometry(geom: geometry.Vector2D, options: map.GeometryOptions): any;
|
|
68
74
|
layerAddGeometry(geometryLayer: any, geom: any): void;
|
package/leaflet.js
CHANGED
|
@@ -540,10 +540,39 @@ export class KMLNetworkLink
|
|
|
540
540
|
|
|
541
541
|
export class LeafletMap extends map.MapControl
|
|
542
542
|
{
|
|
543
|
+
/**
|
|
544
|
+
* @param {L.LeafletMouseEvent} evt
|
|
545
|
+
*/
|
|
546
|
+
onMouseMove(evt)
|
|
547
|
+
{
|
|
548
|
+
if (this.moveFunc)
|
|
549
|
+
{
|
|
550
|
+
this.moveFunc(fromLatLng(evt.latlng));
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @param {string | HTMLElement} divId
|
|
556
|
+
*/
|
|
543
557
|
constructor(divId)
|
|
544
558
|
{
|
|
545
559
|
super();
|
|
546
560
|
this.mapObj = L.map(divId);
|
|
561
|
+
this.moveFunc = null;
|
|
562
|
+
this.popupMarker = null;
|
|
563
|
+
let self = this;
|
|
564
|
+
this.mapObj.on("mousemove", (evt)=> {self.onMouseMove(evt);});
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// @ts-ignore
|
|
568
|
+
getDiv()
|
|
569
|
+
{
|
|
570
|
+
return this.mapObj.getContainer();
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
sizeUpdated()
|
|
574
|
+
{
|
|
575
|
+
this.mapObj.invalidateSize();
|
|
547
576
|
}
|
|
548
577
|
|
|
549
578
|
createLayer(layer, options)
|
|
@@ -551,8 +580,15 @@ export class LeafletMap extends map.MapControl
|
|
|
551
580
|
return createLayer(layer, options);
|
|
552
581
|
}
|
|
553
582
|
|
|
554
|
-
|
|
555
|
-
|
|
583
|
+
createMarkerLayer(name, options)
|
|
584
|
+
{
|
|
585
|
+
return L.layerGroup();
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
createGeometryLayer(name, options)
|
|
589
|
+
{
|
|
590
|
+
return L.layerGroup();
|
|
591
|
+
}
|
|
556
592
|
|
|
557
593
|
addLayer(layer)
|
|
558
594
|
{
|
|
@@ -580,11 +616,18 @@ export class LeafletMap extends map.MapControl
|
|
|
580
616
|
this.mapObj.setZoom(osm.scale2Level(scale));
|
|
581
617
|
}
|
|
582
618
|
|
|
619
|
+
/**
|
|
620
|
+
* @param {math.Coord2D} pos
|
|
621
|
+
*/
|
|
583
622
|
panTo(pos)
|
|
584
623
|
{
|
|
585
624
|
this.mapObj.setView(L.latLng(pos.y, pos.x));
|
|
586
625
|
}
|
|
587
626
|
|
|
627
|
+
/**
|
|
628
|
+
* @param {math.Coord2D} pos
|
|
629
|
+
* @param {number} scale
|
|
630
|
+
*/
|
|
588
631
|
panZoomScale(pos, scale)
|
|
589
632
|
{
|
|
590
633
|
this.mapObj.setView(L.latLng(pos.y, pos.x), osm.scale2Level(scale));
|
|
@@ -595,20 +638,219 @@ export class LeafletMap extends map.MapControl
|
|
|
595
638
|
this.mapObj.fitBounds(toLatLngBounds(extent));
|
|
596
639
|
}
|
|
597
640
|
|
|
598
|
-
/* handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
641
|
+
/* handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void;*/
|
|
642
|
+
/**
|
|
643
|
+
* @param {(mapPos: math.Coord2D)=>void} moveFunc
|
|
644
|
+
*/
|
|
645
|
+
handleMouseMove(moveFunc)
|
|
646
|
+
{
|
|
647
|
+
this.moveFunc = moveFunc;
|
|
648
|
+
}
|
|
649
|
+
/* handlePosChange(posFunc: (mapPos: math.Coord2D)=>void): void;*/
|
|
650
|
+
/**
|
|
651
|
+
* @param {math.Coord2D} mapPos
|
|
652
|
+
*/
|
|
653
|
+
map2ScnPos(mapPos)
|
|
654
|
+
{
|
|
655
|
+
let pt = this.mapObj.latLngToContainerPoint(L.latLng(mapPos.lat, mapPos.lon));
|
|
656
|
+
return new math.Coord2D(pt.x, pt.y);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
scn2MapPos(scnPos)
|
|
660
|
+
{
|
|
661
|
+
let latlng = this.mapObj.containerPointToLatLng(L.point(scnPos.x, scnPos.y));
|
|
662
|
+
return new math.Coord2D(latlng.lng, latlng.lat);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* @param {math.Coord2D} mapPos
|
|
667
|
+
* @param {string} imgURL
|
|
668
|
+
* @param {number} imgWidth
|
|
669
|
+
* @param {number} imgHeight
|
|
670
|
+
* @param {map.MarkerOptions} options
|
|
671
|
+
*/
|
|
672
|
+
createMarker(mapPos, imgURL, imgWidth, imgHeight, options)
|
|
673
|
+
{
|
|
674
|
+
let icon = L.icon({iconUrl: imgURL, iconSize: [imgWidth, imgHeight]});
|
|
675
|
+
let opt = {icon: icon};
|
|
676
|
+
if (options.zIndex)
|
|
677
|
+
{
|
|
678
|
+
opt.zIndexOffset = options.zIndex;
|
|
679
|
+
}
|
|
680
|
+
return L.marker([mapPos.lat, mapPos.lon], opt);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
layerAddMarker(markerLayer, marker)
|
|
684
|
+
{
|
|
685
|
+
marker.addTo(markerLayer);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
layerRemoveMarker(markerLayer, marker)
|
|
689
|
+
{
|
|
690
|
+
markerLayer.removeLayer(marker);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
layerClearMarkers(markerLayer)
|
|
694
|
+
{
|
|
695
|
+
markerLayer.clearLayers();
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
layerMoveMarker(markerLayer, marker, mapPos)
|
|
699
|
+
{
|
|
700
|
+
marker.setLatLng(L.latLng(mapPos.lat, mapPos.lon));
|
|
701
|
+
return marker;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
markerUpdateIcon(markerLayer, marker, url)
|
|
705
|
+
{
|
|
706
|
+
let oldIcon = marker.getIcon();
|
|
707
|
+
marker.setIcon(L.icon({iconUrl: url, iconSize: oldIcon.options.iconSize}));
|
|
708
|
+
return marker;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
markerIsOver(marker, scnPos)
|
|
712
|
+
{
|
|
713
|
+
let icon = marker.getIcon();
|
|
714
|
+
let latlng = marker.getLatLng();
|
|
715
|
+
let sz = icon.options.iconSize;
|
|
716
|
+
let iconPos = this.mapObj.latLngToContainerPoint(latlng);
|
|
717
|
+
if (sz == null)
|
|
718
|
+
return false;
|
|
719
|
+
if ((scnPos.x < iconPos.x - sz[0] * 0.5) || (scnPos.y < iconPos.y - sz[1] * 0.5))
|
|
720
|
+
return false;
|
|
721
|
+
if ((iconPos.x + sz[0] * 0.5 <= scnPos.x) || (iconPos.y + sz[1] * 0.5 <= scnPos.y))
|
|
722
|
+
return false;
|
|
723
|
+
return true;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
markerShowPopup(marker, content, w, h)
|
|
727
|
+
{
|
|
728
|
+
let opt = {closeButton: false, closeOnEscapeKey: false};
|
|
729
|
+
if (w && h)
|
|
730
|
+
{
|
|
731
|
+
opt.minWidth = w;
|
|
732
|
+
opt.maxHeight = h;
|
|
733
|
+
}
|
|
734
|
+
marker.bindPopup(content, opt).openPopup();
|
|
735
|
+
this.popupMarker = marker;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
hidePopup()
|
|
739
|
+
{
|
|
740
|
+
if (this.popupMarker)
|
|
741
|
+
{
|
|
742
|
+
this.popupMarker.closePopup();
|
|
743
|
+
this.popupMarker = null;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* @param {geometry.Vector2D} geom
|
|
749
|
+
* @param {map.GeometryOptions} options
|
|
750
|
+
*/
|
|
751
|
+
createGeometry(geom, options)
|
|
752
|
+
{
|
|
753
|
+
let opt = {};
|
|
754
|
+
if (options.lineColor)
|
|
755
|
+
{
|
|
756
|
+
opt.color = options.lineColor;
|
|
757
|
+
opt.stroke = true;
|
|
758
|
+
opt.weight = options.lineWidth || 1;
|
|
759
|
+
}
|
|
760
|
+
else
|
|
761
|
+
{
|
|
762
|
+
opt.stroke = false;
|
|
763
|
+
}
|
|
764
|
+
if (options.fillColor)
|
|
765
|
+
{
|
|
766
|
+
opt.fill = true;
|
|
767
|
+
opt.fillColor = options.fillColor;
|
|
768
|
+
opt.fillOpacity = options.fillOpacity;
|
|
769
|
+
}
|
|
770
|
+
else
|
|
771
|
+
{
|
|
772
|
+
opt.fill = false;
|
|
773
|
+
}
|
|
774
|
+
if (geom instanceof geometry.Point)
|
|
775
|
+
{
|
|
776
|
+
// return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(geom.coordinates[0], geom.coordinates[1]), null, opt);
|
|
777
|
+
}
|
|
778
|
+
else if (geom instanceof geometry.LinearRing)
|
|
779
|
+
{
|
|
780
|
+
let i;
|
|
781
|
+
let points = [];
|
|
782
|
+
for (i in geom.coordinates)
|
|
783
|
+
{
|
|
784
|
+
points.push([geom.coordinates[i][1], geom.coordinates[i][0]]);
|
|
785
|
+
}
|
|
786
|
+
return L.polygon(points, opt);
|
|
787
|
+
}
|
|
788
|
+
else if (geom instanceof geometry.LineString)
|
|
789
|
+
{
|
|
790
|
+
let i;
|
|
791
|
+
let points = [];
|
|
792
|
+
for (i in geom.coordinates)
|
|
793
|
+
{
|
|
794
|
+
points.push([geom.coordinates[i][1], geom.coordinates[i][0]]);
|
|
795
|
+
}
|
|
796
|
+
return L.polyline(points, opt);
|
|
797
|
+
}
|
|
798
|
+
else if (geom instanceof geometry.Polygon)
|
|
799
|
+
{
|
|
800
|
+
let i;
|
|
801
|
+
let j;
|
|
802
|
+
let lrArr = [];
|
|
803
|
+
for (i in geom.geometries)
|
|
804
|
+
{
|
|
805
|
+
let points = [];
|
|
806
|
+
let lr = geom.geometries[i];
|
|
807
|
+
for (j in lr.coordinates)
|
|
808
|
+
{
|
|
809
|
+
points.push([lr.coordinates[j][1], lr.coordinates[j][0]]);
|
|
810
|
+
}
|
|
811
|
+
lrArr.push(points);
|
|
812
|
+
}
|
|
813
|
+
return L.polygon(lrArr, opt);
|
|
814
|
+
}
|
|
815
|
+
else if (geom instanceof geometry.MultiPolygon)
|
|
816
|
+
{
|
|
817
|
+
let i;
|
|
818
|
+
let j;
|
|
819
|
+
let k;
|
|
820
|
+
let pgArr = [];
|
|
821
|
+
for (i in geom.geometries)
|
|
822
|
+
{
|
|
823
|
+
let lrArr = [];
|
|
824
|
+
let pg = geom.geometries[i];
|
|
825
|
+
for (j in pg.geometries)
|
|
826
|
+
{
|
|
827
|
+
let lr = pg.geometries[j];
|
|
828
|
+
let points = [];
|
|
829
|
+
for (k in lr.coordinates)
|
|
830
|
+
{
|
|
831
|
+
points.push([lr.coordinates[k][1], lr.coordinates[k][0]]);
|
|
832
|
+
}
|
|
833
|
+
lrArr.push(points);
|
|
834
|
+
}
|
|
835
|
+
pgArr.push(lrArr);
|
|
836
|
+
}
|
|
837
|
+
return L.polygon(pgArr, opt);
|
|
838
|
+
}
|
|
839
|
+
throw new Error("Unknown geometry type");
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
layerAddGeometry(geometryLayer, geom)
|
|
843
|
+
{
|
|
844
|
+
geom.addTo(geometryLayer);
|
|
845
|
+
}
|
|
603
846
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
markerIsOver(marker: any, scnPos: math.Coord2D): boolean;
|
|
847
|
+
layerRemoveGeometry(geometryLayer, geom)
|
|
848
|
+
{
|
|
849
|
+
geometryLayer.removeLayer(geom);
|
|
850
|
+
}
|
|
609
851
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
852
|
+
layerClearGeometries(geometryLayer)
|
|
853
|
+
{
|
|
854
|
+
geometryLayer.clearLayers();
|
|
855
|
+
}
|
|
614
856
|
}
|
package/map.d.ts
CHANGED
|
@@ -134,37 +134,47 @@ declare class GeometryOptions
|
|
|
134
134
|
fillOpacity?: number;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
declare class MarkerInfo
|
|
138
|
+
{
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export abstract class MapControl
|
|
138
142
|
{
|
|
139
143
|
constructor();
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
abstract getDiv(): HTMLDivElement;
|
|
145
|
+
abstract sizeUpdated(): void;
|
|
146
|
+
abstract createLayer(layer: map.LayerInfo, options?: LayerOptions): any;
|
|
147
|
+
abstract createMarkerLayer(name: string, options?: LayerOptions): any;
|
|
148
|
+
abstract createGeometryLayer(name: string, options?: LayerOptions): any;
|
|
149
|
+
abstract addLayer(layer: any): void;
|
|
150
|
+
abstract addKML(feature: kml.Feature | kml.KMLFile): void;
|
|
151
|
+
abstract uninit(): void;
|
|
152
|
+
abstract zoomIn(): void;
|
|
153
|
+
abstract zoomOut(): void;
|
|
154
|
+
abstract zoomScale(scale: number): void;
|
|
155
|
+
abstract panTo(pos: math.Coord2D): void;
|
|
156
|
+
abstract panZoomScale(pos: math.Coord2D, scale: number): void;
|
|
157
|
+
abstract zoomToExtent(extent: math.RectArea): void;
|
|
158
|
+
abstract handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void;
|
|
159
|
+
abstract handleMouseMove(moveFunc: (mapPos: math.Coord2D)=>void): void;
|
|
160
|
+
abstract handlePosChange(posFunc: (mapPos: math.Coord2D)=>void): void;
|
|
161
|
+
abstract map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
162
|
+
abstract scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
163
|
+
|
|
164
|
+
abstract createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: MarkerOptions): MarkerInfo;
|
|
165
|
+
abstract layerAddMarker(markerLayer: any, marker: MarkerInfo): void;
|
|
166
|
+
abstract layerRemoveMarker(markerLayer: any, marker: MarkerInfo): void;
|
|
167
|
+
abstract layerClearMarkers(markerLayer: any): void;
|
|
168
|
+
abstract layerMoveMarker(markerLayer: any, marker: MarkerInfo, mapPos: math.Coord2D): MarkerInfo;
|
|
169
|
+
abstract markerUpdateIcon(markerLayer: any, marker: MarkerInfo, url: string): MarkerInfo;
|
|
170
|
+
abstract markerIsOver(marker: MarkerInfo, scnPos: math.Coord2D): boolean;
|
|
171
|
+
abstract markerShowPopup(marker: MarkerInfo, content: string, w?: number, h?: number): void;
|
|
172
|
+
abstract hidePopup();
|
|
173
|
+
|
|
174
|
+
abstract createGeometry(geom: geometry.Vector2D, options: GeometryOptions): any;
|
|
175
|
+
abstract layerAddGeometry(geometryLayer: any, geom: any): void;
|
|
176
|
+
abstract layerRemoveGeometry(geometryLayer: any, geom: any): void;
|
|
177
|
+
abstract layerClearGeometries(geometryLayer: any): void;
|
|
168
178
|
}
|
|
169
179
|
|
|
170
180
|
declare class OWSSpatialReference
|
package/olayer2.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export class Olayer2Map extends map.MapControl
|
|
|
29
29
|
posFunc: (lat: number, lon: number)=>void;
|
|
30
30
|
|
|
31
31
|
constructor(mapId: string);
|
|
32
|
+
getDiv(): HTMLDivElement;
|
|
33
|
+
sizeUpdated(): void;
|
|
32
34
|
createLayer(layer: map.LayerInfo, options?: map.LayerOptions): any;
|
|
33
35
|
createMarkerLayer(name: string, options?: map.LayerOptions): any;
|
|
34
36
|
createGeometryLayer(name: string, options?: map.LayerOptions): any;
|
|
@@ -47,11 +49,15 @@ export class Olayer2Map extends map.MapControl
|
|
|
47
49
|
map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
48
50
|
scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
49
51
|
|
|
50
|
-
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions):
|
|
51
|
-
layerAddMarker(markerLayer: any, marker:
|
|
52
|
-
layerRemoveMarker(markerLayer: any, marker:
|
|
52
|
+
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: map.MarkerOptions): map.MarkerInfo;
|
|
53
|
+
layerAddMarker(markerLayer: any, marker: map.MarkerInfo): void;
|
|
54
|
+
layerRemoveMarker(markerLayer: any, marker: map.MarkerInfo): void;
|
|
53
55
|
layerClearMarkers(markerLayer: any): void;
|
|
54
|
-
|
|
56
|
+
layerMoveMarker(markerLayer: any, marker: MarkerInfo, mapPos: math.Coord2D): MarkerInfo;
|
|
57
|
+
markerUpdateIcon(markerLayer: any, marker: MarkerInfo, url: string): MarkerInfo;
|
|
58
|
+
markerIsOver(marker: map.MarkerInfo, scnPos: math.Coord2D): boolean;
|
|
59
|
+
markerShowPopup(marker: MarkerInfo, content: string, w?: number, h?: number): void;
|
|
60
|
+
hidePopup();
|
|
55
61
|
|
|
56
62
|
createGeometry(geom: geometry.Vector2D, options: map.GeometryOptions): any;
|
|
57
63
|
layerAddGeometry(geometryLayer: any, geom: any): void;
|
package/olayer2.js
CHANGED
|
@@ -235,6 +235,7 @@ export class Olayer2Map extends map.MapControl
|
|
|
235
235
|
this.initY = 22.4;
|
|
236
236
|
this.initLev = 12;
|
|
237
237
|
this.mapId = mapId;
|
|
238
|
+
this.currMarkerPopup = null;
|
|
238
239
|
let dom = document.getElementById(mapId);
|
|
239
240
|
if (dom)
|
|
240
241
|
{
|
|
@@ -288,6 +289,16 @@ export class Olayer2Map extends map.MapControl
|
|
|
288
289
|
this.currMarkerPopupObj = null;
|
|
289
290
|
}
|
|
290
291
|
|
|
292
|
+
getDiv()
|
|
293
|
+
{
|
|
294
|
+
return web.getDivElement(this.mapId);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
sizeUpdated()
|
|
298
|
+
{
|
|
299
|
+
this.map.updateSize();
|
|
300
|
+
}
|
|
301
|
+
|
|
291
302
|
/**
|
|
292
303
|
* @param {map.LayerInfo} layer
|
|
293
304
|
* @param {object} options
|
|
@@ -374,6 +385,9 @@ export class Olayer2Map extends map.MapControl
|
|
|
374
385
|
}
|
|
375
386
|
}
|
|
376
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @param {kml.KMLFile | kml.Feature} feature
|
|
390
|
+
*/
|
|
377
391
|
addKML(feature)
|
|
378
392
|
{
|
|
379
393
|
createFromKML(feature, {map: this.map, objProjection: this.mapProjection, mapProjection: this.map.getProjectionObject()}).then((layer)=>{this.addLayer(layer);});
|
|
@@ -496,17 +510,82 @@ export class Olayer2Map extends map.MapControl
|
|
|
496
510
|
markerLayer.clearMarkers();
|
|
497
511
|
}
|
|
498
512
|
|
|
513
|
+
/**
|
|
514
|
+
* @param {OpenLayers.Layer.Markers} markerLayer
|
|
515
|
+
* @param {OpenLayers.Marker} marker
|
|
516
|
+
* @param {math.Coord2D} mapPos
|
|
517
|
+
*/
|
|
518
|
+
layerMoveMarker(markerLayer, marker, mapPos)
|
|
519
|
+
{
|
|
520
|
+
let newIcon = new OpenLayers.Icon(marker.icon.url, marker.icon.size, marker.icon.offset);
|
|
521
|
+
if (marker.icon.imageDiv.style.zIndex)
|
|
522
|
+
{
|
|
523
|
+
newIcon.imageDiv.style.zIndex = marker.icon.imageDiv.style.zIndex;
|
|
524
|
+
}
|
|
525
|
+
let newMarker = new OpenLayers.Marker(new OpenLayers.LonLat(mapPos.x, mapPos.y).transform(this.mapProjection, this.map.getProjectionObject()), newIcon);
|
|
526
|
+
markerLayer.removeMarker(marker);
|
|
527
|
+
markerLayer.addMarker(newMarker);
|
|
528
|
+
marker.destroy();
|
|
529
|
+
return newMarker;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @param {OpenLayers.Layer.Markers} markerLayer
|
|
534
|
+
* @param {OpenLayers.Marker} marker
|
|
535
|
+
* @param {string} url
|
|
536
|
+
*/
|
|
537
|
+
markerUpdateIcon(markerLayer, marker, url)
|
|
538
|
+
{
|
|
539
|
+
let newIcon = new OpenLayers.Icon(url, marker.icon.size, marker.icon.offset);
|
|
540
|
+
if (marker.icon.imageDiv.style.zIndex)
|
|
541
|
+
{
|
|
542
|
+
newIcon.imageDiv.style.zIndex = marker.icon.imageDiv.style.zIndex;
|
|
543
|
+
}
|
|
544
|
+
let newMarker = new OpenLayers.Marker(marker.lonlat, newIcon);
|
|
545
|
+
markerLayer.removeMarker(marker);
|
|
546
|
+
markerLayer.addMarker(newMarker);
|
|
547
|
+
marker.destroy();
|
|
548
|
+
return newMarker;
|
|
549
|
+
}
|
|
550
|
+
|
|
499
551
|
markerIsOver(marker, scnPos)
|
|
500
552
|
{
|
|
501
553
|
let icon = marker.icon;
|
|
502
|
-
|
|
503
|
-
|
|
554
|
+
let ofst = marker.map.layerContainerOriginPx;
|
|
555
|
+
let ofstX = ofst.x + icon.offset.x;
|
|
556
|
+
let ofstY = ofst.y + icon.offset.y;
|
|
557
|
+
if (icon.px == null)
|
|
558
|
+
return false;
|
|
559
|
+
if ((scnPos.x < icon.px.x + ofstX) || (scnPos.y < icon.px.y + ofstY))
|
|
504
560
|
return false;
|
|
505
|
-
if ((icon.px.x +
|
|
561
|
+
if ((icon.px.x + ofstX + icon.size.w <= scnPos.x) || (icon.px.y + ofstY + icon.size.h <= scnPos.y))
|
|
506
562
|
return false;
|
|
507
563
|
return true;
|
|
508
564
|
}
|
|
509
565
|
|
|
566
|
+
markerShowPopup(marker, content, w, h)
|
|
567
|
+
{
|
|
568
|
+
let popup = new OpenLayers.Popup("marker", marker.lonlat, new OpenLayers.Size(w, h), content, false);
|
|
569
|
+
if (this.currMarkerPopup)
|
|
570
|
+
{
|
|
571
|
+
this.currMarkerPopup.hide();
|
|
572
|
+
}
|
|
573
|
+
this.currMarkerPopup = popup;
|
|
574
|
+
popup.autoSize = true;
|
|
575
|
+
this.map.addPopup(popup);
|
|
576
|
+
popup.show();
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
hidePopup()
|
|
580
|
+
{
|
|
581
|
+
if (this.currMarkerPopup)
|
|
582
|
+
{
|
|
583
|
+
this.currMarkerPopup.hide();
|
|
584
|
+
this.map.removePopup(this.currMarkerPopup);
|
|
585
|
+
this.currMarkerPopup = null;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
510
589
|
/**
|
|
511
590
|
* @param {geometry.Vector2D} geom
|
|
512
591
|
* @param {map.GeometryOptions} options
|