@sswroom/sswr 1.3.1 → 1.4.0
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/geometry.d.ts +4 -0
- package/geometry.js +21 -0
- package/kml.d.ts +11 -1
- package/kml.js +78 -28
- package/leaflet.d.ts +3 -1
- package/leaflet.js +21 -3
- package/map.d.ts +93 -7
- package/map.js +70 -0
- package/olayer2.d.ts +54 -0
- package/olayer2.js +492 -0
- package/package.json +1 -1
- package/sswr.js +1 -0
- package/web.d.ts +1 -0
- package/web.js +363 -20
package/olayer2.js
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import * as geometry from "./geometry.js";
|
|
2
|
+
import * as kml from "./kml.js";
|
|
3
|
+
import * as map from "./map.js";
|
|
4
|
+
import * as math from "./math.js";
|
|
5
|
+
import * as web from "./web.js";
|
|
6
|
+
|
|
7
|
+
export class Olayer2Map extends map.MapControl
|
|
8
|
+
{
|
|
9
|
+
constructor(mapId)
|
|
10
|
+
{
|
|
11
|
+
super();
|
|
12
|
+
this.inited = false;
|
|
13
|
+
this.mapId = mapId;
|
|
14
|
+
var dom = document.getElementById(mapId);
|
|
15
|
+
dom.style.minWidth = '1px';
|
|
16
|
+
dom.style.minHeight = '1px';
|
|
17
|
+
this.mapProjection = new OpenLayers.Projection("EPSG:4326");
|
|
18
|
+
this.map = new OpenLayers.Map(this.mapId, {
|
|
19
|
+
eventListeners: {
|
|
20
|
+
"moveend": ()=>{this.eventMoved();},
|
|
21
|
+
"zoomend": ()=>{this.eventMoved();},
|
|
22
|
+
"mousemove": (e)=>{this.eventMouseMoved(e);}
|
|
23
|
+
},
|
|
24
|
+
controls: [
|
|
25
|
+
new OpenLayers.Control.PanZoomBar(),
|
|
26
|
+
new OpenLayers.Control.Navigation()
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
this.Click = OpenLayers.Class(OpenLayers.Control, {
|
|
31
|
+
defaultHandlerOptions: {
|
|
32
|
+
'single': true,
|
|
33
|
+
'double': false,
|
|
34
|
+
'pixelTolerance': 0,
|
|
35
|
+
'stopSingle': false,
|
|
36
|
+
'stopDouble': false
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
initialize: function(options) {
|
|
40
|
+
this.handlerOptions = OpenLayers.Util.extend(
|
|
41
|
+
{}, this.defaultHandlerOptions
|
|
42
|
+
);
|
|
43
|
+
OpenLayers.Control.prototype.initialize.apply(
|
|
44
|
+
this, arguments
|
|
45
|
+
);
|
|
46
|
+
this.handler = new OpenLayers.Handler.Click(
|
|
47
|
+
this, {
|
|
48
|
+
'click': this.trigger
|
|
49
|
+
}, this.handlerOptions
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
trigger: (e)=>{this.eventLClicked(e);}
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
this.mouseCtrl = new this.Click();
|
|
58
|
+
this.map.addControl(this.mouseCtrl);
|
|
59
|
+
this.mouseCtrl.activate();
|
|
60
|
+
this.currMarkerPopup = null;
|
|
61
|
+
this.currMarkerPopupObj = null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
createLayer(layer, options)
|
|
65
|
+
{
|
|
66
|
+
if (layer.type == map.WebMapType.OSMTile)
|
|
67
|
+
{
|
|
68
|
+
return new OpenLayers.Layer.OSM(layer.name, [layer.url]);
|
|
69
|
+
}
|
|
70
|
+
else if (layer.type == map.WebMapType.ArcGIS)
|
|
71
|
+
{
|
|
72
|
+
return new OpenLayers.Layer.ArcGIS93Rest(layer.name, [layer.url]);
|
|
73
|
+
}
|
|
74
|
+
else if (layer.type == map.WebMapType.WMS)
|
|
75
|
+
{
|
|
76
|
+
return new OpenLayers.Layer.WMS(layer.name, layer.url, {layers: layer.layers});
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
createMarkerLayer(name, options)
|
|
82
|
+
{
|
|
83
|
+
var layer = new OpenLayers.Layer.Markers(name);
|
|
84
|
+
return layer;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
createGeometryLayer(name, options)
|
|
88
|
+
{
|
|
89
|
+
var layer = new OpenLayers.Layer.Vector(name);
|
|
90
|
+
return layer;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
addLayer(layer)
|
|
94
|
+
{
|
|
95
|
+
this.map.addLayer(layer);
|
|
96
|
+
if (!this.inited)
|
|
97
|
+
{
|
|
98
|
+
this.inited = true;
|
|
99
|
+
this.map.setCenter(
|
|
100
|
+
new OpenLayers.LonLat(114.2, 22.4).transform(
|
|
101
|
+
this.mapProjection,
|
|
102
|
+
this.map.getProjectionObject()
|
|
103
|
+
), 12);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
uninit()
|
|
108
|
+
{
|
|
109
|
+
this.map.destroy();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
zoomIn()
|
|
113
|
+
{
|
|
114
|
+
this.map.zoomIn();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
zoomOut()
|
|
118
|
+
{
|
|
119
|
+
this.map.zoomOut();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
zoomScale(scale)
|
|
123
|
+
{
|
|
124
|
+
this.map.zoomToScale(scale, false);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
panTo(pos)
|
|
128
|
+
{
|
|
129
|
+
this.map.panTo(new OpenLayers.LonLat(pos.x, pos.y).transform(this.mapProjection, this.map.getProjectionObject()));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
panZoomScale(pos, scale)
|
|
133
|
+
{
|
|
134
|
+
this.map.zoomToScale(scale, false);
|
|
135
|
+
this.map.setCenter(new OpenLayers.LonLat(pos.x, pos.y).transform(this.mapProjection, this.map.getProjectionObject()), this.map.getZoom(), false, false);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
zoomToExtent(extent)
|
|
139
|
+
{
|
|
140
|
+
var pos = extent.getCenter();
|
|
141
|
+
var currZoom = this.map.getZoom();
|
|
142
|
+
var tl = this.map2ScnPos(new math.Coord2D(extent.min.x, extent.max.y));
|
|
143
|
+
var br = this.map2ScnPos(new math.Coord2D(extent.max.x, extent.min.y));
|
|
144
|
+
var scnSize = this.map.getSize();
|
|
145
|
+
var ratioX = (br.x - tl.x) / scnSize.w;
|
|
146
|
+
var ratioY = (br.y - tl.y) / scnSize.h;
|
|
147
|
+
if (ratioY > ratioX)
|
|
148
|
+
{
|
|
149
|
+
ratioX = ratioY;
|
|
150
|
+
}
|
|
151
|
+
var minZoom = 0;
|
|
152
|
+
var maxZoom = this.map.getNumZoomLevels() - 1;
|
|
153
|
+
currZoom += Math.floor(-Math.log(ratioX) / Math.log(2));
|
|
154
|
+
if (currZoom < 0)
|
|
155
|
+
currZoom = 0;
|
|
156
|
+
if (currZoom > maxZoom)
|
|
157
|
+
currZoom = maxZoom;
|
|
158
|
+
this.map.setCenter(new OpenLayers.LonLat(pos.x, pos.y).transform(this.mapProjection, this.map.getProjectionObject()), currZoom, false, false);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
handleMouseLClick(clickFunc)
|
|
162
|
+
{
|
|
163
|
+
this.lclickFunc = clickFunc;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
handleMouseMove(moveFunc)
|
|
167
|
+
{
|
|
168
|
+
this.moveFunc = moveFunc;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
handlePosChange(posFunc)
|
|
172
|
+
{
|
|
173
|
+
this.posFunc = posFunc;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
map2ScnPos(mapPos)
|
|
177
|
+
{
|
|
178
|
+
var scnPx = this.map.getViewPortPxFromLonLat(new OpenLayers.LonLat(mapPos.x, mapPos.y).transform(this.mapProjection, this.map.getProjectionObject()));
|
|
179
|
+
return new math.Coord2D(scnPx.x, scnPx.y);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
scn2MapPos(scnPos)
|
|
183
|
+
{
|
|
184
|
+
var lonLat = this.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(scnPos.x, scnPos.y)).transform(this.map.getProjectionObject(), this.mapProjection);
|
|
185
|
+
return new math.Coord2D(lonLat.lon, lonLat.lat);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
createMarker(mapPos, imgURL, imgWidth, imgHeight, options)
|
|
189
|
+
{
|
|
190
|
+
var size = new OpenLayers.Size(imgWidth, imgHeight);
|
|
191
|
+
var offset = new OpenLayers.Pixel(-(size.w / 2), -(size.h / 2));
|
|
192
|
+
var icon = new OpenLayers.Icon(imgURL, size, offset);
|
|
193
|
+
if (options && options.zIndex)
|
|
194
|
+
{
|
|
195
|
+
icon.imageDiv.style.zIndex = options.zIndex;
|
|
196
|
+
}
|
|
197
|
+
return new OpenLayers.Marker(new OpenLayers.LonLat(mapPos.x, mapPos.y).transform(this.mapProjection, this.map.getProjectionObject()), icon);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
layerAddMarker(markerLayer, marker)
|
|
201
|
+
{
|
|
202
|
+
markerLayer.addMarker(marker);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
layerRemoveMarker(markerLayer, marker)
|
|
206
|
+
{
|
|
207
|
+
markerLayer.removeMarker(marker);
|
|
208
|
+
marker.destroy();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
layerClearMarkers(markerLayer)
|
|
212
|
+
{
|
|
213
|
+
markerLayer.clearMarkers();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
markerIsOver(marker, scnPos)
|
|
217
|
+
{
|
|
218
|
+
var icon = marker.icon;
|
|
219
|
+
//alert("x="+x+", y="+y+", px.x="+icon.px.x+", px.y="+icon.px.y+", offset.x="+icon.offset.x+", offset.y="+icon.offset.y+", size.w="+icon.size.w+", size.h="+icon.size.h+", debug="+(icon.px.x + icon.px.offset.x + icon.size.w));
|
|
220
|
+
if ((scnPos.x < icon.px.x + icon.offset.x) || (scnPos.y < icon.px.y + icon.offset.y))
|
|
221
|
+
return false;
|
|
222
|
+
if ((icon.px.x + icon.offset.x + icon.size.w <= scnPos.x) || (icon.px.y + icon.offset.y + icon.size.h <= scnPos.y))
|
|
223
|
+
return false;
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
createGeometry(geom, options)
|
|
228
|
+
{
|
|
229
|
+
var opt = {};
|
|
230
|
+
if (options.lineColor)
|
|
231
|
+
{
|
|
232
|
+
opt.strokeColor = options.lineColor;
|
|
233
|
+
opt.stroke = true;
|
|
234
|
+
opt.strokeWidth = options.lineWidth || 1;
|
|
235
|
+
}
|
|
236
|
+
else
|
|
237
|
+
{
|
|
238
|
+
opt.stroke = false;
|
|
239
|
+
}
|
|
240
|
+
if (options.fillColor)
|
|
241
|
+
{
|
|
242
|
+
opt.fill = true;
|
|
243
|
+
opt.fillColor = options.fillColor;
|
|
244
|
+
opt.fillOpacity = options.fillOpacity;
|
|
245
|
+
}
|
|
246
|
+
else
|
|
247
|
+
{
|
|
248
|
+
opt.fill = false;
|
|
249
|
+
}
|
|
250
|
+
if (geom instanceof geometry.Point)
|
|
251
|
+
{
|
|
252
|
+
return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(geom.coordinates[0], geom.coordinates[1]), null, opt);
|
|
253
|
+
}
|
|
254
|
+
else if (geom instanceof geometry.LinearRing)
|
|
255
|
+
{
|
|
256
|
+
var i;
|
|
257
|
+
var points = [];
|
|
258
|
+
for (i in geom.coordinates)
|
|
259
|
+
{
|
|
260
|
+
var pos = new OpenLayers.LonLat(geom.coordinates[i][0], geom.coordinates[i][1]).transform(this.mapProjection, this.map.getProjectionObject());
|
|
261
|
+
points.push(new OpenLayers.Geometry.Point(pos.lon, pos.lat));
|
|
262
|
+
}
|
|
263
|
+
return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LinearRing(points), null, opt);
|
|
264
|
+
}
|
|
265
|
+
else if (geom instanceof geometry.LineString)
|
|
266
|
+
{
|
|
267
|
+
var i;
|
|
268
|
+
var points = [];
|
|
269
|
+
for (i in geom.coordinates)
|
|
270
|
+
{
|
|
271
|
+
var pos = new OpenLayers.LonLat(geom.coordinates[i][0], geom.coordinates[i][1]).transform(this.mapProjection, this.map.getProjectionObject());
|
|
272
|
+
points.push(new OpenLayers.Geometry.Point(pos.lon, pos.lat));
|
|
273
|
+
}
|
|
274
|
+
return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(points), null, opt);
|
|
275
|
+
}
|
|
276
|
+
else if (geom instanceof geometry.Polygon)
|
|
277
|
+
{
|
|
278
|
+
var i;
|
|
279
|
+
var j;
|
|
280
|
+
var lrArr = [];
|
|
281
|
+
for (i in geom.geometries)
|
|
282
|
+
{
|
|
283
|
+
var points = [];
|
|
284
|
+
var lr = geom.geometries[i];
|
|
285
|
+
for (j in lr.coordinates)
|
|
286
|
+
{
|
|
287
|
+
var pos = new OpenLayers.LonLat(lr.coordinates[j][0], lr.coordinates[j][1]).transform(this.mapProjection, this.map.getProjectionObject());
|
|
288
|
+
points.push(new OpenLayers.Geometry.Point(pos.lon, pos.lat));
|
|
289
|
+
}
|
|
290
|
+
lrArr.push(new OpenLayers.Geometry.LineString(points));
|
|
291
|
+
}
|
|
292
|
+
return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon(lrArr), null, opt);
|
|
293
|
+
}
|
|
294
|
+
else if (geom instanceof geometry.MultiPolygon)
|
|
295
|
+
{
|
|
296
|
+
var i;
|
|
297
|
+
var j;
|
|
298
|
+
var k;
|
|
299
|
+
var pgArr = [];
|
|
300
|
+
for (i in geom.geometries)
|
|
301
|
+
{
|
|
302
|
+
var lrArr = [];
|
|
303
|
+
var pg = geom.geometries[i];
|
|
304
|
+
for (j in pg.geometries)
|
|
305
|
+
{
|
|
306
|
+
var lr = pg.geometries[j];
|
|
307
|
+
var points = [];
|
|
308
|
+
for (k in lr.coordinates)
|
|
309
|
+
{
|
|
310
|
+
var pos = new OpenLayers.LonLat(lr.coordinates[k][0], lr.coordinates[k][1]).transform(this.mapProjection, this.map.getProjectionObject());
|
|
311
|
+
points.push(new OpenLayers.Geometry.Point(pos.lon, pos.lat));
|
|
312
|
+
}
|
|
313
|
+
lrArr.push(new OpenLayers.Geometry.LineString(points));
|
|
314
|
+
}
|
|
315
|
+
pgArr.push(new OpenLayers.Geometry.Polygon(lrArr));
|
|
316
|
+
}
|
|
317
|
+
return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.MultiPolygon(pgArr), null, opt);
|
|
318
|
+
}
|
|
319
|
+
throw new Error("Unknown geometry type");
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
layerAddGeometry(geometryLayer, geometry)
|
|
323
|
+
{
|
|
324
|
+
geometryLayer.addFeatures([geometry]);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
layerRemoveGeometry(geometryLayer, geom)
|
|
328
|
+
{
|
|
329
|
+
geometryLayer.removeFeatures([geom]);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
layerClearGeometries(goemetryLayer)
|
|
333
|
+
{
|
|
334
|
+
goemetryLayer.removeAllFeatures();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
toKMLFeature(layer, doc)
|
|
338
|
+
{
|
|
339
|
+
var feature;
|
|
340
|
+
if (doc == null || !(doc instanceof kml.Document))
|
|
341
|
+
{
|
|
342
|
+
doc = new kml.Document();
|
|
343
|
+
feature = this.toKMLFeature(layer, doc);
|
|
344
|
+
if (feature)
|
|
345
|
+
{
|
|
346
|
+
doc.addFeature(feature);
|
|
347
|
+
return doc;
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
if (layer instanceof OpenLayers.Layer.Markers)
|
|
352
|
+
{
|
|
353
|
+
var featureGroup = new kml.Folder();
|
|
354
|
+
featureGroup.setName(layer.name || "Markers");
|
|
355
|
+
var i;
|
|
356
|
+
for (i in layer.markers)
|
|
357
|
+
{
|
|
358
|
+
feature = this.toKMLFeature(layer.markers[i], doc);
|
|
359
|
+
if (feature)
|
|
360
|
+
featureGroup.addFeature(feature);
|
|
361
|
+
}
|
|
362
|
+
return featureGroup;
|
|
363
|
+
}
|
|
364
|
+
else if (layer instanceof OpenLayers.Marker)
|
|
365
|
+
{
|
|
366
|
+
var pos = layer.lonlat.transform(this.map.getProjectionObject(), this.mapProjection);
|
|
367
|
+
feature = new kml.Placemark(new geometry.Point(4326, [pos.lon, pos.lat]));
|
|
368
|
+
feature.setName("Marker");
|
|
369
|
+
var icon = layer.icon;
|
|
370
|
+
if (icon)
|
|
371
|
+
{
|
|
372
|
+
var iconStyle = new kml.IconStyle();
|
|
373
|
+
if (icon.url.startsWith("/"))
|
|
374
|
+
{
|
|
375
|
+
var durl = document.location.href;
|
|
376
|
+
var i = durl.indexOf("://");
|
|
377
|
+
i = durl.indexOf("/", i + 3);
|
|
378
|
+
if (i >= 0)
|
|
379
|
+
{
|
|
380
|
+
iconStyle.setIconUrl(durl.substring(0, i)+icon.url);
|
|
381
|
+
}
|
|
382
|
+
else
|
|
383
|
+
{
|
|
384
|
+
iconStyle.setIconUrl(durl+icon.url);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else
|
|
388
|
+
{
|
|
389
|
+
iconStyle.setIconUrl(icon.url);
|
|
390
|
+
}
|
|
391
|
+
iconStyle.setHotSpotX(-icon.offset.x / icon.size.w);
|
|
392
|
+
iconStyle.setHotSpotY(-icon.offset.y / icon.size.h);
|
|
393
|
+
feature.setStyle(doc.getOrNewStyle(iconStyle, null, null, null, null, null));
|
|
394
|
+
}
|
|
395
|
+
return feature;
|
|
396
|
+
}
|
|
397
|
+
else if (layer instanceof OpenLayers.Layer.Vector)
|
|
398
|
+
{
|
|
399
|
+
var featureGroup = new kml.Folder();
|
|
400
|
+
featureGroup.setName(layer.name || "Vector");
|
|
401
|
+
var i;
|
|
402
|
+
for (i in layer.features)
|
|
403
|
+
{
|
|
404
|
+
feature = this.toKMLFeature(layer.features[i], doc);
|
|
405
|
+
if (feature)
|
|
406
|
+
featureGroup.addFeature(feature);
|
|
407
|
+
}
|
|
408
|
+
return featureGroup;
|
|
409
|
+
}
|
|
410
|
+
else if (layer instanceof OpenLayers.Feature.Vector)
|
|
411
|
+
{
|
|
412
|
+
var lineStyle = null;
|
|
413
|
+
var polyStyle = null;
|
|
414
|
+
if (layer.style)
|
|
415
|
+
{
|
|
416
|
+
if (layer.style.stroke)
|
|
417
|
+
{
|
|
418
|
+
var c = web.parseCSSColor(layer.style.strokeColor);
|
|
419
|
+
lineStyle = new kml.LineStyle();
|
|
420
|
+
lineStyle.fromARGB(c.a, c.r, c.g, c.b);
|
|
421
|
+
if (layer.style.strokeWidth)
|
|
422
|
+
lineStyle.setWidth(layer.style.strokeWidth)
|
|
423
|
+
}
|
|
424
|
+
if (layer.style.fill)
|
|
425
|
+
{
|
|
426
|
+
var c = web.parseCSSColor(layer.style.fillColor);
|
|
427
|
+
if (layer.style.fillOpacity)
|
|
428
|
+
c.a = c.a * layer.style.fillOpacity;
|
|
429
|
+
polyStyle = new kml.PolyStyle();
|
|
430
|
+
polyStyle.fromARGB(c.a, c.r, c.g, c.b);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
var vec;
|
|
434
|
+
var geom = layer.geometry;
|
|
435
|
+
if (geom instanceof OpenLayers.Geometry.LinearRing)
|
|
436
|
+
{
|
|
437
|
+
var pts = [];
|
|
438
|
+
var i;
|
|
439
|
+
for (i in geom.components)
|
|
440
|
+
{
|
|
441
|
+
var pt = new OpenLayers.LonLat(geom.components[i].x, geom.components[i].y).transform(this.map.getProjectionObject(), this.mapProjection);
|
|
442
|
+
pts.push([pt.lon, pt.lat]);
|
|
443
|
+
}
|
|
444
|
+
vec = new geometry.LinearRing(4326, pts);
|
|
445
|
+
}
|
|
446
|
+
else
|
|
447
|
+
{
|
|
448
|
+
throw new Error("Unsupported type of geometry");
|
|
449
|
+
}
|
|
450
|
+
var placemark = new kml.Placemark(vec);
|
|
451
|
+
placemark.setStyle(doc.getOrNewStyle(null, null, lineStyle, polyStyle, null, null));
|
|
452
|
+
return placemark;
|
|
453
|
+
}
|
|
454
|
+
else
|
|
455
|
+
{
|
|
456
|
+
console.log("Unknown type", layer);
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
eventLClicked(e)
|
|
462
|
+
{
|
|
463
|
+
if (this.lclickFunc)
|
|
464
|
+
{
|
|
465
|
+
var lonlat = this.map.getLonLatFromViewPortPx(e.xy).transform(this.map.getProjectionObject(), this.mapProjection);
|
|
466
|
+
this.lclickFunc(lonlat.lat, lonlat.lon, e.xy.x, e.xy.y);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
eventMoved()
|
|
471
|
+
{
|
|
472
|
+
if (this.map == null)
|
|
473
|
+
return;
|
|
474
|
+
if (this.posFunc)
|
|
475
|
+
{
|
|
476
|
+
var cent = this.map.getCenter().transform(this.map.getProjectionObject(), this.mapProjection);
|
|
477
|
+
this.posFunc(new math.Coord2D(cent.lon, cent.lat));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
eventMouseMoved(event)
|
|
482
|
+
{
|
|
483
|
+
if (this.map == null)
|
|
484
|
+
return;
|
|
485
|
+
if (this.moveFunc)
|
|
486
|
+
{
|
|
487
|
+
var pos = this.map.events.getMousePosition(event);
|
|
488
|
+
var cent = this.map.getLonLatFromViewPortPx(pos).transform(this.map.getProjectionObject(), this.mapProjection);
|
|
489
|
+
this.moveFunc(new math.Coord2D(cent.lon, cent.lat));
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
package/package.json
CHANGED
package/sswr.js
CHANGED
|
@@ -6,6 +6,7 @@ export * as kml from "./kml.js";
|
|
|
6
6
|
export * as leaflet from "./leaflet.js";
|
|
7
7
|
export * as map from "./map.js";
|
|
8
8
|
export * as math from "./math.js";
|
|
9
|
+
export * as olayer2 from "./olayer2.js";
|
|
9
10
|
export * as osm from "./osm.js";
|
|
10
11
|
export * as text from "./text.js";
|
|
11
12
|
export * as unit from "./unit.js";
|
package/web.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export function loadJSON(url: string, onResultFunc: Function): void;
|
|
|
12
12
|
export function buildTable(o: object | object[]): string;
|
|
13
13
|
export function openData(data: string, contentType: string, fileName?: string): void;
|
|
14
14
|
export function parseCSSColor(c: string): Color;
|
|
15
|
+
export function handleFileDrop(ele: HTMLElement, hdlr: (file: any)=>void): void;
|
|
15
16
|
|
|
16
17
|
declare class DialogButton
|
|
17
18
|
{
|