forked from svgmap/svgmapjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSVGMapLv0.1_Authoring_r8_module.js
executable file
·2965 lines (2661 loc) · 105 KB
/
SVGMapLv0.1_Authoring_r8_module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Description:
// SVG Map Authoring Tools Extention for > Rev.14 of SVGMap Level0.1 Framework
//
// Programmed by Satoru Takagi
//
// Copyright (C) 2016-2023 by Satoru Takagi @ KDDI CORPORATION
//
// License: (GPL v3)
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 3 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// History:
// Rev1: Rev11以前の内蔵システム
// 2016/12/16 Rev2: Start Porting from Rev11 code and Modularization
// 2016/12/21 Base FW Rev11のオーサリングコードとほぼ同等(以上)のものを移植完了
// 2016/12/28 Rev3: Polygon/Polyline Tools
// 2017/01/30 Rev4: Rubber Band for Polyline/Polygon
// 2017/02/03 Rev5: Point入力UIのTextArea使用を廃止する(for Tablet devices)
// 2017/02/xx Rev6: ポリゴンUIのdelete機能を改善
// 2017/03/17 zoomPanMap -> screenRefreshed + zoomPanMap
// 2017/06/09 Rev7: add POIregistTool
// 2018/02/01 minor bug fix
// 2018/02/02 cursor.style.zIndexを設定するようにした(toBeDel on rev15対策)
// 2018/03/05 polylineを編集できる機能をおおよそ実装
// 2019/03/12 POIのアイコン定義が1個しかない場合はアイコン選択UI省略
// 2019/03/12 タイリングされたレイヤーに対して処理可能にする(制約としては、タイルにあるオブジェクトを編集したものは保持されない。新規のオブジェクトはレイヤルートに設置。メタデータスキーマ・アイコン定義は、共通のものをレイヤールートにも設置必要)
// 2019/12/27 refreshScreen後コールバック処理の精密化
// 2020/01/21 同上マイナー修正
// 2020/07/17 redis用でブランチしていた機能を取り込み(poiToolsの帰り値オプション)
// 2021/03/16 POIregistTool(initPOIregistToolの方)でタッチイベントでの座標入力に対応、また座標入力のキャンセル関数を設けた
// 2021/06/23 複数のレイヤーでツールが起動されたとき、処理が破綻したのをひとまず回避(まだ不完全かも。特に状態を保持するline/polygon系)
//
// ESM fork SVGMapLv0.2_Authoring_r7_
// 2023/06/06 polylineの操作性向上。polygonも最初の一点可視化
// 2023/06/14 Rev8: バッファ付きポイント・ライン・ポリゴンUI、6個のUIを統合したUI(initGenericTool)
// 2023/06/19 POIもoptionsで設定するように変更。 bufferedのvecrot-effectバグ修正、 いずれでもeditingStyle,shapeStyleを設定可能に(POIの場合はbuiffered時有効)
// 2023/06/20 GenericTool周りのコードのブラッシュアップ、editingStyle,shapeStyleを設定可能に
// 2023/08/10 フリーハンドツール実装
//
// ToDo,ISSUES:
// POI以外の描画オブジェクトを選択したときに出るイベントbase fwに欲しい
// 編集UIを出した状態で、TypeError: svgImagesProps[layerId] is undefined[詳細] SVGMapLv0.1_r14.js:3667:3
// POIToolsとPolytoolsが排他処理が完全ではない
// 複数のレイヤーでツールが起動されたとき、処理が破綻している? (2021/06で対応できたか?)このライブラリは基本的にレイヤーにカプセル化されていない・・リファクタリングすべき ひとまず破綻しないようにしてみた
// 重なったオブジェクトが標準UIの中で選べない
// Notes:
// root containerでclass=editableの設定がないと、再編集や、レイヤ消去後の再表示での編集結果の保持はできない 2018.2.5
// path は 以下のルールとしておこう・・
// zが一個でも付いたら無条件でポリゴン認定、
// zが一個もない場合
// fill="none"でポリライン認定
// fillなしもしくはnone以外でポリゴン認定
// Notes:
// root containerでclass=editableの設定がないと、再編集や、レイヤ消去後の再表示での編集結果の保持はできない 2018.2.5
import { SvgMapGIS } from './SVGMapLv0.1_GIS_r4_module.js';
class SvgMapAuthoringTool {
#svgMap;
#mapViewerProps;
#svgMapGIStool;
constructor(svgMapObject, mapViewerProps){
console.log("Hello this is svgMapAuthoringTool");
this.#svgMap = svgMapObject;
this.#mapViewerProps = mapViewerProps;
this.#svgMapGIStool=new SvgMapGIS(svgMapObject, window.jsts);
console.log("construct SvgMapAuthoringTool: svgMapObject: ",svgMapObject);
}
//var editLayerTitle = ""; // 編集対象のレイヤーのtitle属性(もしくは
//var action = "none"; // 起こしたアクションがなんなのか(かなりいい加減・・)2013/1 (for Dynamic Layer)
// handleResultに入れてある
// var layers=getEditableLayers();
// 開いている編集UIに関するグローバル情報を入れているオブジェクト
// uiMapping = {uiPanel,editingLayerId,editingMode,uiDoc,editingGraphicsElement,modifyTargetElement,toolsCbFunc,toolsCbFuncParam,genericMode{panel,editingStyle,shapeStyle,withBufferedTools},editingStyle,shapeStyle,bufferOption,editedElement}
// uiPanel : オーサリングUIを発生させる(layer specific UI iframe中などの)div要素
// editingLayerId : 編集中のSVG文書のレイヤーID(svgMapProps[]などの)
// editingMode : POI,POLYLINE,POIreg...
// uiDoc : uiPanelのオーナードキュメント(layer specific UI iframe中などのhtml)
// editingGraphicsElement : 図形要素を編集中かどうか(boolean)
// modifyTargetElement : 既存図形要素を改変中かどうか(そうならばその要素のNode)
// selectedPointsIndex,insertPointsIndex: Poly*用の編集対象ポイント ない場合は-1
// toolsCbFunc : コールバック 2019/3/12
// toolsCbFuncParam : コールバック関数の任意パラメータ
// genericMode: .panel: ポリゴン、ポリライン、ポイント、(さらに拡張)全部乗せUIの時に設定される、div要素, .editingStyle, .shapeStyle : 共通のスタイル, withBufferedTools: bufferedツールあるときはtrue
// shapeStyle, edigingStyle : 図形のスタイルや編集中のスタイル
// bufferOption : バッファー生成オプション
// editedElement : polylie/polygon/POI(full)編集ツールで編集したオブジェクト
#uiMapping = {};
#uiMappingG ={}; // uiMapping[layerID]:uiMapping layerID毎にuiMappingを入れる 2021/6/23
#defaultShapeStyle = {
strokeWidth:3,
opacity:1,
fill:"skyblue",
stroke:"blue",
};
#defaultEditingStyle = {
strokeWidth:3,
opacity:1,
fill:"yellow",
stroke:"red",
};
#editPoint( x , y ){
var geop = this.#svgMap.screen2Geo( x , y );
console.log("Get EditPoint event! :",geop);
// POIAppend( geop , isEditingLayer().getAttribute("iid") ,"TEST");
// まず、すべてのレイヤーイベントリスナ(含パンズーム)を停止させる?(やってない)
// かわりに、指定したレイヤーのPOIに新しいイベントリスナーを設置する?
//
}
#POIAppend( geoLocation , docId ,title){
var layerSVGDOM = this.#svgImages[docId];
var layerCRS = this.#svgImagesProps[docId].CRS;
var symbols = this.#svgMap.getSymbols(this.#svgImages[docId]);
// var metaSchema = layerSVGDOM.ownerDocument.documentElement.getAttribute("property").split(",");
if ( layerCRS && layerSVGDOM && symbols ){
var symbd = layerSVGDOM.getElementsByTagName("defs");
if ( symbd[0].getElementsByTagName("g") ){
var firstSymbol = null;
for ( var key in symbols ){
firstSymbol = symbols[key];
// console.log(key);
break;
}
// var symbolId = firstSymbol.getAttribute("id");
var svgxy = this.#svgMap.Geo2SVG( geoLocation.lat , geoLocation.lng , layerCRS )
var tf = "ref(svg," + svgxy.x + "," + svgxy.y + ")";
var nssvg = layerSVGDOM.documentElement.namespaceURI;
var poi = layerSVGDOM.createElementNS(nssvg,"use"); // FirefoxではちゃんとNSを設定しないと大変なことになるよ^^; 2013/7/30
poi.setAttribute("x" , 0);
poi.setAttribute("y" , 0);
// poi.setAttribute("transform" , tf);
poi.setAttributeNS(nssvg,"transform" , tf);
poi.setAttribute("xlink:href" , "#" + firstSymbol.id);
poi.setAttribute("xlink:title" , title);
poi.setAttribute("content" , "null");
layerSVGDOM.documentElement.appendChild(poi);
// console.log(layerSVGDOM);
// console.log("POIAppend::",poi.parentNode);
// POIeditSelection(poi);
// console.log("addPoi:",poi,poi.getAttribute("xtransform"),poi.getAttribute("transform"));
//dynamicLoad( "root" , mapCanvas );
this.#svgMap.refreshScreen();
// console.log("call poi edit props");
setTimeout(function(){POIeditProps(poi,true,symbols);}.bind(this),50);
}
}
}
#clearTools = function( e ){
console.log( "call clear tools");
var targetDoc = this.#uiMapping.uiDoc;
var confStat = "Cancel";
this.#editConfPhase2( targetDoc, this.#uiMapping.toolsCbFunc, this.#uiMapping.toolsCbFuncParam, confStat );
this.#terminateFreeHandAuthoring();
// 以下editConfPhase2で済み
// poiCursor.removeCursor();
// polyCanvas.removeCanvas();
// clearForms(uiMapping.uiDoc);
if ( this.#uiMapping.modifyTargetElement && this.#uiMapping.modifyTargetElement.getAttribute("iid") && document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid")) ){
document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid")).style.backgroundColor="";
}
this.#uiMapping.modifyTargetElement=null;
this.#uiMapping.editingGraphicsElement = false;
console.log( "get iframe close/hide event from authoring tools framework.");
this.#svgMap.setRootLayersProps(this.#uiMapping.editingLayerId, null , false );
this.#removePointEvents( this.#editPolyPoint );
// svgMap.refreshScreen();
}.bind(this);
#setTools = function( e ){
console.log( "get iframe appear event from authoring tools framework.");
this.#svgMap.setRootLayersProps(this.#uiMapping.editingLayerId, true , true );
}.bind(this);
// 特定POINTオブジェクトの登録ツール・座標入力ツール 特定のIDを持ったuse要素を登録(上書き)複数設置できる
// 座標の登録のみ アイコンやプロパティの編集は出来ない(init時にあらかじめの設定は可能)
#initPOIregistTool(targetDiv,poiDocId,poiId,iconId,title,metaData,cbFunc,cbFuncParam,getPointOnly,returnSvgElement){
var uiDoc = targetDiv.ownerDocument;
// iconId: svg文書でdefsされたID setPoiSvg()に仕様により、"#"頭についたものをuiMapping.poiParams[].hrefに送る必要あるので・・
if ( iconId.indexOf("#")!=0){
iconId = "#"+iconId;
}
if ( this.#uiMapping && this.#uiMapping.editingMode && this.#uiMapping.editingMode=="POIreg" && uiDoc === this.#uiMapping.uiDoc && poiDocId == this.#uiMapping.editingLayerId){ // すでにそのUIdocでPOIregモードの初期化済みのときは二個目以降のツールが追加されていく。このときcbFuncは無視・・
console.log("ADD uiMapping");
} else { // uiMappingを新規作成する系
console.log("NEW uiMapping");
this.#initUiMapping({
uiPanel : [],
editingLayerId : poiDocId,
editingMode : "POIreg",
uiDoc: uiDoc,
editingGraphicsElement: false,
modifyTargetElement: null,
poiParams:[],
returnSvgElement:returnSvgElement,
selectedPointsIndex:-1
}) ;
if ( cbFunc ){
this.#uiMapping.toolsCbFunc = cbFunc;
this.#uiMapping.toolsCbFuncParam = cbFuncParam;
} else {
this.#uiMapping.toolsCbFunc = null;
this.#uiMapping.toolsCbFuncParam = null;
}
}
this.#uiMapping.uiPanel.push(targetDiv);
this.#uiMapping.poiParams.push(
{
title:title,
metadata:metaData,
href:iconId,
id:poiId,
}
);
var toolNumb = this.#uiMapping.uiPanel.length-1;
this.#removeChildren(targetDiv);
console.log("called initPOIregistTool: docId:",poiDocId);
this.#svgImages = this.#svgMap.getSvgImages();
this.#svgImagesProps = this.#svgMap.getSvgImagesProps();
var symbols = this.#svgMap.getSymbols(this.#svgImages[poiDocId]);
var metaSchema = this.#getMetaSchema(poiDocId);
var centerRegButton=uiDoc.createElement("input");
centerRegButton.setAttribute("type","button");
centerRegButton.id="cernterRegButton"+toolNumb;
centerRegButton.setAttribute("value","mapCenterCoord");
var coordInputButton = uiDoc.createElement("input");
coordInputButton.setAttribute("type","button");
coordInputButton.id="coordInputButton"+toolNumb;
coordInputButton.setAttribute("value","lat/lng");
var coordTextBox = uiDoc.createElement("input");
coordTextBox.setAttribute("type","text");
coordTextBox.id="coordTextBox"+toolNumb;
coordTextBox.setAttribute("value","---,---");
targetDiv.appendChild(centerRegButton);
targetDiv.appendChild(coordInputButton);
targetDiv.appendChild(coordTextBox);
this.#setPoiRegUiEvents(targetDiv);
}
// POINTオブジェクト(use)の"編集"ツール 新規追加、削除、変更などが可能 ただし一個しか設置できない
#svgImages;
#svgImagesProps;
#initPOItools(targetDiv,poiDocId,cbFunc,cbFuncParam,getPointOnly,returnSvgElement,options,){
var bufferOption = false;
if ( options?.bufferOption){
bufferOption = options.bufferOption;
}
// getPointOnlyuse: useは作るものの 作った後に座標を取得してすぐに捨てるような使い方(アイコンを打つわけではない)
this.#removeChildren(targetDiv);
var uiDoc = targetDiv.ownerDocument;
console.log("called initPOItools: docId:",poiDocId);
this.#svgMap.setRootLayersProps(poiDocId, true , true ); // 子docの場合もあり得ると思う・・
this.#svgImages = this.#svgMap.getSvgImages();
this.#svgImagesProps = this.#svgMap.getSvgImagesProps();
var symbols = this.#svgMap.getSymbols(this.#svgImages[poiDocId]);
var metaSchema = this.#getMetaSchema(poiDocId);
var symbolCount = 0;
for ( var key in symbols ){
++symbolCount;
}
var ihtml = '<table id="poiEditor">';
if ( symbolCount > 1 ){
ihtml += '<tr><td colspan="2" id="iconselection" >';
} else { // アイコンが一個しかないときはアイコン選択UIは不要でしょう 2018.6.21
ihtml += '<tr style="display:none"><td colspan="2" id="iconselection" >';
}
var firstSymbol = true;
for ( var key in symbols ){ // srcに相対パスが正しく入っているか?
if ( symbols[key].type=="symbol"){
// console.log(key , poiHref);
// console.log(key,getImagePath(symbols[key].path,poiDocId));
ihtml+='<img id="symbol'+key+'" src="' + symbols[key].path + '" width="' + symbols[key].width + '" height="' + symbols[key].height + '" property="' + key + '" ';
if ( firstSymbol ){
ihtml += 'border="2" style="border-color:red" ';
firstSymbol = false;
} else {
ihtml += 'border="2" style="border-color:white" ';
}
ihtml+='/>';
}
}
ihtml += '</td></tr>';
if ( !getPointOnly ){
ihtml += '<tr><td>title</td><td><input type="text" id="poiEditorTitle" value="' + "title" + '"/></td></tr>';
}
ihtml += '<tr><td><input type="button" id="pointUI" value="lat/lng"/></td><td><input id="poiEditorPosition" type="text" value="--,--"/></td></tr></table>'
ihtml += '<table id="metaEditor">';
if ( metaSchema ){
var latMetaCol,lngMetaCol,titleMetaCol; // 位置とtitleがメタデータにも用意されている(ダブっている)ときに、それらのカラム番号が設定される。
for ( var i = 0 ; i < metaSchema.length ; i++ ){
var mdval ="";
if ( metaSchema[i] == "title" || metaSchema[i] == "name" || metaSchema[i] == "名称" || metaSchema[i] == "タイトル" ){
titleMetaCol =i;
ihtml+='<tr><td>' + metaSchema[i] + '</td><td><input id="meta'+i+'" type="text" data-type="titleMetaCol" disabled="disabled" value="'+"title"+'"/></td></tr>';
} else if ( metaSchema[i] == "latitude" || metaSchema[i] == "lat" || metaSchema[i] == "緯度"){
latMetaCol = i;
ihtml+='<tr><td>' + metaSchema[i] + '</td><td><input id="meta'+i+'" type="text" data-type="latMetaCol" disabled="disabled" value="' + "numberFormat(latlng.lat )" + '"/></td></tr>';
} else if ( metaSchema[i] == "longitude"|| metaSchema[i] == "lon" || metaSchema[i] == "lng" || metaSchema[i] == "経度"){
lngMetaCol = i;
ihtml+='<tr><td>' + metaSchema[i] + '</td><td><input id="meta'+i+'" type="text" data-type="lngMetaCol" disabled="disabled" value="' + "numberFormat(latlng.lng )" + '"/></td></tr>';
} else {
ihtml+='<tr><td>' + metaSchema[i] + '</td><td><input id="meta'+i+'" type="text" value="' + mdval + '"/></td></tr>';
}
}
}
ihtml+='</table>';
if ( bufferOption ){
ihtml +='<div><input type="text" id="objectBufferLength" value="" placeholder="バッファ半径[m]"></input></div>';
}
ihtml+='<div id="editConf"><input type="button" id="pepok" value="決定"/><input type="button" id="pepng" value="キャンセル"/><input type="button" id="pepdel" disabled value="削除"/><span id="editMode">newObject</span></div>';
targetDiv.innerHTML = ihtml;
// addPoiEditEvents(document.getElementById(poiDocId));
this.#initUiMapping( {
uiPanel : targetDiv,
editingLayerId : poiDocId,
editingMode : "POI",
uiDoc: uiDoc,
editingGraphicsElement: false,
modifyTargetElement: null,
returnSvgElement: returnSvgElement,
selectedPointsIndex:-1,
editingStyle:structuredClone(this.#defaultEditingStyle), // bufferedの時に有効になる
shapeStyle:structuredClone(this.#defaultShapeStyle), // 同上
}, true );
if ( cbFunc ){
this.#uiMapping.toolsCbFunc = cbFunc;
this.#uiMapping.toolsCbFuncParam = cbFuncParam;
} else {
this.#uiMapping.toolsCbFunc = null;
this.#uiMapping.toolsCbFuncParam = null;
}
if ( bufferOption ){
this.#uiMapping.bufferOption = true;
}
this.#setUiStyle(this.#uiMapping.editingStyle, options?.editingStyle);
this.#setUiStyle(this.#uiMapping.shapeStyle, options?.shapeStyle);
this.#setPoiUiEvents(uiDoc, poiDocId);
this.#setMetaUiEvents(uiDoc, poiDocId);
this.#setEditConfEvents(uiDoc, poiDocId);
return ( this.#uiMapping );
}
#setMetaUiEvents(targetDoc){
targetDoc.getElementById("metaEditor").addEventListener("click",function(e){
console.log( this.#getMetaUiData(targetDoc));
switch ( e.target.id ){
}
}.bind(this),false);
}
#getMetaUiData(targetDoc){
var metaAns = [];
var tbl = targetDoc.getElementById("metaEditor");
for ( var i = 0 ; i < tbl.rows.length ; i++ ){
// console.log(tbl.rows[i].cells[1]);
metaAns.push(tbl.rows[i].cells[1].childNodes[0].value);
}
return ( metaAns );
}
#getAllAttrs(elem){
var attrs = elem.attributes;
var ret={};
for (var i = 0 ; i < attrs.length; i++) {
ret[attrs[i].name]=attrs[i].value;
}
return ( ret );
}
#setEditConfEvents( targetDoc , poiDocId){
this.#pointAddMode = false;
targetDoc.getElementById("editConf").addEventListener("click",function(e){
console.log("editConf event : id:",e.target.id, " editMode:",this.#uiMapping);
if ( this.#uiMapping.editingMode ==="POLYLINE" || this.#uiMapping.editingMode ==="POLYGON"){
this.#removePointEvents( this.#editPolyPoint );
}
var confStat;
if ( this.#uiMapping.modifyTargetElement ){
this.#uiMapping.prevAttrs = this.#getAllAttrs(this.#uiMapping.modifyTargetElement);
}
var ret=null;
switch ( e.target.id ){
case"pepok": // 値設定決定用
confStat = "OK";
if ( this.#uiMapping.editingMode ==="POI"){
// clearPoiSelection();
ret = this.#setPoiSvg(this.#readPoiUiParams(targetDoc),poiDocId);
// 既存アイコンを選択しているものがあれば(SVGではなく、HTMLの方を)元に戻す
// console.log(uiMapping.modifyTargetElement,document.getElementById(uiMapping.modifyTargetElement.getAttribute("iid")));
if ( this.#uiMapping.modifyTargetElement && document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid"))){
document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid")).style.backgroundColor="";
if ( ret ){
document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid")).title =ret.getAttribute("xlink:title");
}
}
} else if ( this.#uiMapping.editingMode ==="POLYLINE" || this.#uiMapping.editingMode ==="POLYGON"){
ret = this.#setPolySvg(targetDoc,poiDocId);
} else if (this.#uiMapping.editingMode === "FREEHAND") {
if (this.#uiMapping.editingGraphicsElement != true) {
return;
}
// フリーハンドツール用の終了処理はこれのみ キャンセルはここにはない
console.log("FREEHAND tools editconf");
ret = this.#setFreeHandSvgElement(targetDoc, poiDocId); // options次第で輪郭にするかビットイメージにするかを変える必要がある
this.#terminateFreeHandAuthoring();
}
this.#uiMapping.modifyTargetElement=null;
this.#uiMapping.editingGraphicsElement=false;
break;
case"pepng": // キャンセル用
confStat = "Cancel";
console.log("do cancel",this.#uiMapping.editingMode);
// POIのケースで既存アイコンを選択しているものがあれば(SVGではなく、HTMLの方を)元に戻す
if ( this.#uiMapping.modifyTargetElement && document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid"))){
document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid")).style.backgroundColor="";
}
this.#uiMapping.modifyTargetElement=null;
this.#uiMapping.editingGraphicsElement = false;
// if ( uiMapping.editingMode ==="POI"){
// } else if ( uiMapping.editingMode ==="POLYLINE"){
// polyCanvas.removeCanvas();
// }
break;
case"pepdel": // 削除 2017.2.27 delにpolygonの要素ポイントの削除機能を拡張する
console.log("pepdel button: selP",this.#uiMapping.selectedPointsIndex, " insP:",this.#uiMapping.insertPointsIndex);
if ( this.#uiMapping.selectedPointsIndex == -1 ){
this.#svgMap.setCustomModal("Delete Object?",["YES","Cancel"],this.#delConfModal,{targetDoc:targetDoc,toolsCbFunc:this.#uiMapping.toolsCbFunc,toolsCbFuncParam:this.#uiMapping.toolsCbFuncParam});
/**
confStat = "Delete";
uiMapping.editingGraphicsElement = false;
var svgElem = uiMapping.modifyTargetElement;
svgElem.parentNode.removeChild(svgElem);
uiMapping.modifyTargetElement=null;
**/
} else {
console.log("remove a point not skip edit conf");
confStat = null;
var geoPoints = this.#polyCanvas.getPoints();
geoPoints.splice(this.#uiMapping.selectedPointsIndex , 1 );
this.#uiMapping.selectedPointsIndex = -1;
this.#polyCanvas.setPoints(geoPoints);
this.#updatePointListForm( this.#uiMapping.uiDoc.getElementById("polyEditorPosition") , geoPoints );
}
break;
}
if ( ret ){
if ( this.#uiMapping.bufferOption ){
this.#bufferObject(ret);
} else {
ret.removeAttribute("data-geometry");
}
}
this.#uiMapping.editedElement = ret;
if ( confStat ){
this.#editConfPhase2( targetDoc, this.#uiMapping.toolsCbFunc, this.#uiMapping.toolsCbFuncParam, confStat );
}
}.bind(this),false);
}
#editConfPhase2( targetDoc, toolsCbFunc, toolsCbFuncParam, confStat ){
// console.log("editConfPhase2:",confStat," toolsCbFunc:",toolsCbFunc);
this.#uiMapping.selectedPointsIndex = -1;
this.#uiMapping.insertPointsIndex = -1;
this.#clearForms(targetDoc);
this.#poiCursor.removeCursor();
this.#polyCanvas.removeCanvas();
// console.log("editConfPhase2: toolsCbFunc?:",toolsCbFunc);
if ( toolsCbFunc ){
var retVal;
if ( this.#uiMapping.returnSvgElement){ // 2020/7/17
var attrs = null;
if ( this.#uiMapping.editedElement ){
attrs = this.#getAllAttrs(this.#uiMapping.editedElement);
}
retVal =
{
confStat:confStat,
element:this.#uiMapping.editedElement,
attrs: attrs,
prevAttrs:this.#uiMapping.prevAttrs
}
this.#uiMapping.prevAttrs = null;
this.#uiMapping.editedElement = null;
} else {
retVal = confStat;
}
this.#callAfterRefreshed(toolsCbFunc,retVal,toolsCbFuncParam);
// callAfterRefreshed(toolsCbFunc,confStat,toolsCbFuncParam);
// toolsCbFunc(confStat, toolsCbFuncParam);
}
this.#svgMap.refreshScreen();
}
#delConfModal=function(index,opt){
if ( index == 0 ){
var confStat = "Delete";
this.#uiMapping.editingGraphicsElement = false;
var svgElem = this.#uiMapping.modifyTargetElement;
svgElem.parentNode.removeChild(svgElem);
this.#uiMapping.modifyTargetElement=null;
this.#editConfPhase2( opt.targetDoc, opt.toolsCbFunc, opt.toolsCbFuncParam, confStat );
} else {
// do nothing
}
}.bind(this);
#clearForms(targetDoc){
console.log("clearForms");
if ( this.#uiMapping.modifyTargetElement && this.#uiMapping.modifyTargetElement.getAttribute("iid")){
document.getElementById(this.#uiMapping.modifyTargetElement.getAttribute("iid")).style.backgroundColor="";
this.#uiMapping.modifyTargetElement = null;
}
if ( targetDoc.getElementById("pepdel") ){
targetDoc.getElementById("pepdel").disabled=true;
}
if ( targetDoc.getElementById("editMode") ){
targetDoc.getElementById("editMode").innerHTML="newObject";
}
if ( this.#uiMapping.editingMode ==="POI"){
var tbl = targetDoc.getElementById("poiEditor");
var symbs = tbl.rows[0].cells[0].childNodes;
for ( var i = 0 ; i < symbs.length ; i++ ){
if ( i==0 ){
symbs[i].style.borderColor = "red";
} else {
symbs[i].style.borderColor = "white";
}
}
// tbl.rows[1].cells[1].childNodes[0].value="";
// tbl.rows[2].cells[1].childNodes[0].value="--,--";
if ( targetDoc.getElementById("poiEditorTitle") ){
targetDoc.getElementById("poiEditorTitle").value="";
}
targetDoc.getElementById("poiEditorPosition").value="--,--";
} else if ( this.#uiMapping.editingMode ==="POLYLINE" || this.#uiMapping.editingMode ==="POLYGON"){
var tbl = targetDoc.getElementById("polyEditorPosition");
this.#removeChildren(tbl);
tbl.innerHTML='<tr><td><input type="button" id="pointAdd" value="ADD"/></td></tr>';
}
var tbl = targetDoc.getElementById("metaEditor");
if ( tbl){
for ( var i = 0 ; i < tbl.rows.length ; i++ ){
// console.log(tbl.rows[i].cells[1]);
tbl.rows[i].cells[1].childNodes[0].value="";
}
}
}
#setPoiSvg(poiParams, poiDocId, targetPoiId){
// targetPoiId: svg文書に任意に設定したID(svgと対応htmlに設定されるiidではない!), poiParams:{title,geoPos[lat,lng],metadata,href}
console.log("setPoiSvg called :", poiParams,poiDocId,targetPoiId);
var targetId;
if ( this.#uiMapping.modifyTargetElement ){
targetId = this.#uiMapping.modifyTargetElement.getAttribute("iid");
}
var poiElem;
var poiDoc = this.#svgImages[poiDocId];
if ( targetId ){
poiElem = this.#svgMap.getElementByImageId(poiDoc,targetId); // getElementByIdじゃないのよね・・・
if (!poiElem){ // edit existing POI
poiDocId = this.#uiMapping.modifyTargetElement.ownerDocument.documentElement.getAttribute("about");
poiDoc = this.#svgImages[poiDocId];
poiElem = this.#svgMap.getElementByImageId(poiDoc,targetId);
if ( ! poiElem ){
// poiElem = poiDoc.createElement("use");
// このケースは原理上はあってはならない エラー
console.log("Can not find element.... Exit...");
return ( false );
} else {
console.log("Tiled Doc....continue");
}
}
} else if ( targetPoiId ){
if ( poiDoc.getElementById(targetPoiId) ){
poiElem = poiDoc.getElementById(targetPoiId);
} else {
poiElem = poiDoc.createElement("use");
poiElem.setAttribute("id",targetPoiId);
poiDoc.documentElement.appendChild(poiElem);
}
} else {
poiElem = poiDoc.createElement("use");
// nextsibling.....? なんか無造作すぎる気もする・・・
poiDoc.documentElement.appendChild(poiElem);
}
var param = poiParams;
console.log("setPoiSvg:",param);
if ( param.geoPos[0] ){
var svgPoint = this.#svgMap.Geo2SVG( param.geoPos[0] , param.geoPos[1] , this.#svgImagesProps[poiDocId].CRS);
if ( param.metadata ){
var metaStr = "";
for ( var i = 0 ; i < param.metadata.length ; i++ ){
metaStr += this.#svgMap.escape(param.metadata[i]);
if ( i == param.metadata.length -1 ){
break;
}
metaStr += ",";
}
poiElem.setAttribute("content",metaStr);
}
if ( param.title ){
poiElem.setAttribute("xlink:title",param.title);
}
poiElem.setAttribute("transform" , "ref(svg,"+svgPoint.x + ","+svgPoint.y+")");
if ( param.href ){
poiElem.setAttribute("xlink:href", param.href);
}
poiElem.setAttribute("data-geometry",JSON.stringify({type:"Point",coordinates:[param.geoPos[1],param.geoPos[0]],icon:param.href}));
console.log("setPoiSvg:",poiElem);
return ( poiElem );
} else {
// ERROR
return ( false );
}
}
#setPolySvg(targetDoc,poiDocId){
console.log("setPolySvg:",targetDoc,poiDocId);
var targetSvgElem = null;
var geoPoints = this.#polyCanvas.getPoints();
if ( geoPoints.length < 2 || (this.#uiMapping.editingMode == "POLYGON" && geoPoints.length < 3) ){
return ( false );
}
var gtype ="LineString";
if (this.#uiMapping.editingMode== "POLYGON"){
gtype ="Polygon";
}
if ( this.#uiMapping.modifyTargetElement && ( this.#uiMapping.modifyTargetElement.nodeName == "polygon" || this.#uiMapping.modifyTargetElement.nodeName == "polyline" ) ){
// 編集対象が既存オブジェクトであり、polygon,pathの場合
targetSvgElem = this.#uiMapping.modifyTargetElement;
var d="";
for ( var i = 0 ; i < geoPoints.length ; i++ ){
var svgPoint = this.#svgMap.Geo2SVG( geoPoints[i].lat , geoPoints[i].lng , this.#svgImagesProps[poiDocId].CRS);
d+=svgPoint.x+","+svgPoint.y+" ";
}
targetSvgElem.setAttribute("points",d);
} else {
// 編集対象が新規もしくは既存pathオブジェクトの場合
if ( this.#uiMapping.modifyTargetElement){
targetSvgElem = this.#uiMapping.modifyTargetElement;
} else {
var poiDoc = this.#svgImages[poiDocId];
targetSvgElem = poiDoc.createElement("path");
if ( this.#uiMapping.editingMode == "POLYGON" ){
targetSvgElem.setAttribute("fill", this.#uiMapping.shapeStyle.fill);
} else {
targetSvgElem.setAttribute("fill","none");
}
targetSvgElem.setAttribute("opacity", this.#uiMapping.shapeStyle.opacity);
targetSvgElem.setAttribute("stroke", this.#uiMapping.shapeStyle.stroke);
targetSvgElem.setAttribute("stroke-width", this.#uiMapping.shapeStyle.strokeWidth);
targetSvgElem.setAttribute("vector-effect","non-scaling-stroke");
poiDoc.documentElement.appendChild(targetSvgElem);
}
var d="";
for ( var i = 0 ; i < geoPoints.length ; i++ ){
var svgPoint = this.#svgMap.Geo2SVG( geoPoints[i].lat , geoPoints[i].lng , this.#svgImagesProps[poiDocId].CRS);
if ( i == 0 ){
d="M"+svgPoint.x+","+svgPoint.y+"L";
} else {
d+=svgPoint.x+","+svgPoint.y+" ";
}
}
if ( this.#uiMapping.editingMode == "POLYGON"){
d+="z";
} else {
}
targetSvgElem.setAttribute("d",d);
var meta = this.#getMetaUiData(targetDoc);
var metaStr = "";
for ( var i = 0 ; i < meta.length ; i++ ){
metaStr += this.#svgMap.escape(meta[i]);
if ( i == meta.length -1 ){
break;
}
metaStr += ",";
}
targetSvgElem.setAttribute("content",metaStr);
}
var crds=[];
for ( var gp of geoPoints){
crds.push([gp.lng, gp.lat]);
}
if ( gtype =="Polygon"){
if ( crds[0][0] != crds[crds.length-1][0] || crds[0][1] != crds[crds.length-1][1] ){
// 端が閉じてないのはgeojson的にはpolygonじゃないので
crds.push([crds[0][0],crds[0][1]]);
}
crds = [crds];
}
targetSvgElem.setAttribute("data-geometry",JSON.stringify({type:gtype,coordinates:crds}));
return (targetSvgElem);
}
#readPoiUiParams(targetDoc){
var meta = this.#getMetaUiData(targetDoc);
var tbl = targetDoc.getElementById("poiEditor");
var symbs = tbl.rows[0].cells[0].childNodes;
var symbolHref;
for ( var i = 0 ; i < symbs.length ; i++ ){
if ( symbs[i].style.borderColor === "red" ){
symbolHref = symbs[i].getAttribute("property");
break;
}
}
console.log("readPoiUiParams:symbols:",symbs," symHref:",symbolHref);
// var title = tbl.rows[1].cells[1].childNodes[0].value;
var title="";
if ( targetDoc.getElementById("poiEditorTitle")){
title = targetDoc.getElementById("poiEditorTitle").value
}
// var geoPos = tbl.rows[2].cells[1].childNodes[0].value.split(",");
var geoPos = targetDoc.getElementById("poiEditorPosition").value.split(",");
console.log(geoPos);
geoPos[0]=Number(geoPos[0]);
geoPos[1]=Number(geoPos[1]);
// geoPos及びtitleに相当する重複メタデータを上書きする 2017.6.1
var tbl = targetDoc.getElementById("metaEditor");
for ( var i = 0 ; i < tbl.rows.length ; i++ ){
// console.log(tbl.rows[i].cells[1].childNodes[0]);
if ( tbl.rows[i].cells[1].childNodes[0].dataset.type ){
if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="latMetaCol"){
meta[i]=geoPos[0]+""; // 文字列化しないとescape関数がエラー起こす..
} else if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="lngMetaCol"){
meta[i]=geoPos[1]+"";
} else if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="titleMetaCol"){
meta[i]=title;
}
}
}
return {
title: title,
geoPos : geoPos,
metadata : meta,
href : symbolHref
}
}
#setPoiRegPosition(e,targetTxtBoxId, directPutPoiParams){ // setPoiPositionはこれで置き換えの方向
var targetDoc = this.#uiMapping.uiDoc;
var mxy = this.#svgMap.getMouseXY(e);
var geop = this.#svgMap.screen2Geo(mxy.x , mxy.y );
console.log("XY:",mxy, " latlng:",geop, " form:",targetDoc.getElementById("poiEditorPosition"));
targetDoc.getElementById(targetTxtBoxId).value= this.#svgMap.numberFormat(geop.lat) + "," + this.#svgMap.numberFormat(geop.lng);
// document.removeEventListener("click", setPoiRegPosition, false);
if ( !directPutPoiParams ){
this.#poiCursor.setCursorGeo(geop);
} else {
this.#setPoiSvg(
{title:directPutPoiParams.title,geoPos:[geop.lat,geop.lng],metadata:directPutPoiParams.metadata,href:directPutPoiParams.href},
this.#uiMapping.editingLayerId,
directPutPoiParams.id
);
if ( this.#uiMapping.toolsCbFunc ){
this.#callAfterRefreshed(this.#uiMapping.toolsCbFunc,true,this.#uiMapping.toolsCbFuncParam);
// toolsCbFunc(true, toolsCbFuncParam); // refreshが完了してから呼ばないと行儀が悪く、問題が出るようになった(2019/12/27)
}
this.#svgMap.refreshScreen();
}
// メタデータで緯度経度重複のあるdisabled formに値をコピー
console.log("setPoiRegPosition: copy lat lng to meta");
if ( targetDoc.getElementById("metaEditor")){
var tbl = targetDoc.getElementById("metaEditor");
for ( var i = 0 ; i < tbl.rows.length ; i++ ){
console.log(tbl.rows[i].cells[1].childNodes[0]);
if ( tbl.rows[i].cells[1].childNodes[0].dataset.type ){
if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="latMetaCol"){
tbl.rows[i].cells[1].childNodes[0].value = this.#svgMap.numberFormat(geop.lat);
} else if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="lngMetaCol"){
tbl.rows[i].cells[1].childNodes[0].value = this.#svgMap.numberFormat(geop.lng);
}
}
}
}
}
// 2021/3/16 マウスクリックだけでなくタッチイベントにも対応させる
// キャンセルも可能にする(cancelPointingPoiRegister)
#pointingPoiRegister(targetTxtBoxId,directPutPoiParams){
this.#cancelPointingPoiRegister();
this.#pointingPoiRegObject={
targetTxtBoxId:targetTxtBoxId,
directPutPoiParams:directPutPoiParams
}
this.#addPointEvents(this.#pointingPoiRegisterListener);
//addEventListener("click",pointingPoiRegisterListener,false);
//addEventListener("touchend",pointingPoiRegisterListener,false);
}
// POIのUIのクリック・タッチイベント聞き取り状態は排他的なのでクロージャ内に一個の管理オブジェクトがあれば良いはず
#pointingPoiRegObject={};
#pointingPoiRegisterListener=function(event){
this.#setPoiRegPosition(event, this.#pointingPoiRegObject.targetTxtBoxId, this.#pointingPoiRegObject.directPutPoiParams);
this.#cancelPointingPoiRegister();
}.bind(this)
#cancelPointingPoiRegister(){
this.#pointingPoiRegObject={};
this.#removePointEvents(this.#pointingPoiRegisterListener);
//removeEventListener("click",pointingPoiRegisterListener,false);
//removeEventListener("touchend",pointingPoiRegisterListener,false);
}
#callAfterRefreshed(cbf,cbfParam0,cbfParam1){ // refreshが完了してから呼ぶための関数(2019/12/27)
console.log("set cbf on callAfterRefreshed :", cbf,cbfParam0,cbfParam1);
if ( typeof(cbf)!="function"){return}
window.addEventListener('screenRefreshed', (function(cbf,cbfParam0,cbfParam1) {
var f = function() {
console.log("catch screenRefreshed call:",cbf," param:",cbfParam0,cbfParam1)
window.removeEventListener('screenRefreshed', f, false);
cbf(cbfParam0,cbfParam1);
}.bind(this)
return (f);
}.bind(this))(cbf,cbfParam0,cbfParam1), false);
}
#setPoiRegUiEvents( targetDiv ){ // setPoiUiEventsはこれで置き換えの方向
targetDiv.addEventListener("click",function(e){
console.log("get PoiRegUiEvents: targetId:",e.target.id);
if ( e.target.parentNode.id =="pointUI"){// 緯度経度のカーソル入力用
console.log("pointUIev");
setTimeout(function(){
this.#pointingPoiRegister("poiEditorPosition");
// document.addEventListener("click", function(ev){setPoiRegPosition(ev , "poiEditorPosition" )} , false );
}.bind(this),100);
} else if ( e.target.parentNode.id =="iconselection"){
for ( var i = 0 ; i < e.target.parentNode.childNodes.length ; i++ ){
e.target.parentNode.childNodes[i].setAttribute("style","border-color:white");
}
e.target.setAttribute("style","border-color:red");
var selectedPoiHref = e.target.getAttribute("property");
console.log("selPoi:",selectedPoiHref);
} else if ( (e.target.id).indexOf("coordInputButton")==0){
var targetUInumber = Number((e.target.id).substring(16));
console.log("coordInputButton event numb:",targetUInumber);
setTimeout(function(){
this.#pointingPoiRegister("coordTextBox"+targetUInumber , this.#uiMapping.poiParams[targetUInumber]);
/** pointingPoiRegisterで置き換え(2021/3/16)
document.addEventListener("click", function(ev){
setPoiRegPosition(ev , "coordTextBox"+targetUInumber , uiMapping.poiParams[targetUInumber]);
document.removeEventListener("click", arguments.callee, false);
} , false );
**/
}.bind(this),100);
} else if ( (e.target.id).indexOf("cernterRegButton")==0){
var targetUInumber = Number((e.target.id).substring(16));
var geop = this.#svgMap.getCentralGeoCoorinates();
console.log("map center coord Input Button event numb:",targetUInumber,geop, this.#uiMapping.poiParams);
this.#uiMapping.uiDoc.getElementById("coordTextBox"+targetUInumber).value= this.#svgMap.numberFormat(geop.lat) + "," + this.#svgMap.numberFormat(geop.lng);
var params = this.#uiMapping.poiParams[targetUInumber];
this.#setPoiSvg(
{title:params.title,geoPos:[geop.lat,geop.lng],metadata:params.metadata,href:params.href},
this.#uiMapping.editingLayerId,
params.id
);
if ( this.#uiMapping.toolsCbFunc ){
this.#callAfterRefreshed(this.#uiMapping.toolsCbFunc,true,this.#uiMapping.toolsCbFuncParam);
// toolsCbFunc(true, toolsCbFuncParam);
}
this.#svgMap.refreshScreen();
}
}.bind(this),false);
}
#setPoiPosition=function(e){
var targetDoc = this.#uiMapping.uiDoc;
var mxy = this.#svgMap.getMouseXY(e);
var geop = this.#svgMap.screen2Geo(mxy.x , mxy.y );
this.#poiCursor.setCursorGeo(geop);
// cursor.style.left = (screenPoint.x - 6) + "px";
// cursor.style.top = (screenPoint.y - 6)+ "px";
console.log("XY:",mxy, " latlng:",geop, " form:",targetDoc.getElementById("poiEditorPosition"));
// values[2].value= numberFormat(geop.lat) + "," + numberFormat(geop.lng);
targetDoc.getElementById("poiEditorPosition").value= this.#svgMap.numberFormat(geop.lat) + "," + this.#svgMap.numberFormat(geop.lng);
document.removeEventListener("click", this.#setPoiPosition, false);
// メタデータで緯度経度重複のあるdisabled formに値をコピー
console.log("setPoiPosition: copy lat lng to meta");
var tbl = targetDoc.getElementById("metaEditor");
for ( var i = 0 ; i < tbl.rows.length ; i++ ){
console.log(tbl.rows[i].cells[1].childNodes[0]);
if ( tbl.rows[i].cells[1].childNodes[0].dataset.type ){
if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="latMetaCol"){
tbl.rows[i].cells[1].childNodes[0].value = this.#svgMap.numberFormat(geop.lat);
} else if ( tbl.rows[i].cells[1].childNodes[0].dataset.type=="lngMetaCol"){
tbl.rows[i].cells[1].childNodes[0].value = this.#svgMap.numberFormat(geop.lng);
}
}
}
}.bind(this)
#setPoiUiEvents( targetDoc){
targetDoc.getElementById("poiEditor").addEventListener("click",function(e){
console.log("PoiUiEvent: targetId:",e.target.id);
switch ( e.target.id ){
case"pointUI": // 緯度経度のカーソル入力用
console.log("pointUIev");
setTimeout(function(){
document.addEventListener("click", this.#setPoiPosition , false );
}.bind(this),100);
break;
}
if ( e.target.parentNode.id =="iconselection"){
for ( var i = 0 ; i < e.target.parentNode.childNodes.length ; i++ ){
e.target.parentNode.childNodes[i].setAttribute("style","border-color:white");
}
e.target.setAttribute("style","border-color:red");
var selectedPoiHref = e.target.getAttribute("property");