puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="openCityForm">
 
            <input type="hidden" id="id" name="id" value="${item.id}">
            <input type="hidden" id="content" name="content" value='${item.content}'>
            <div class="row">
                <div class="col-sm-10">
                    @if(language==1){
                    <div class="form-group">
                        <label class="col-sm-3 control-label">中文城市名称:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="chineseName" name="chineseName" value="${item.chineseName}" type="text" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">英文城市名称:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="englishName" name="englishName" value="${item.englishName}" type="text" disabled>
 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">印尼文城市名称:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="indonesianName" name="indonesianName" value="${item.indonesianName}" type="text" disabled>
 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">服务范围:</label>
                        <div class="col-sm-9">
                            <div id="map" style="height: 500px;width: 100%;" disabled></div>
                        </div>
                    </div>
                    @}
                    @if(language==2){
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Chinese city name:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="chineseName" name="chineseName" value="${item.chineseName}" type="text" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">English city name:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="englishName" name="englishName" value="${item.englishName}" type="text" disabled>
 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">City name in Indonesian:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="indonesianName" name="indonesianName" value="${item.indonesianName}" type="text" disabled>
 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Service scope:</label>
                        <div class="col-sm-9">
                            <div id="map" style="height: 500px;width: 100%;" disabled></div>
                        </div>
                    </div>
                    @}
                    @if(language==3){
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Nama kota dalam bahasa cina:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="chineseName" name="chineseName" value="${item.chineseName}" type="text" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Nama kota dalam bahasa inggris:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="englishName" name="englishName" value="${item.englishName}" type="text" disabled>
 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Nama kota indonesia:</label>
                        <div class="col-sm-9">
                            <input class="form-control" id="indonesianName" name="indonesianName" value="${item.indonesianName}" type="text" disabled>
 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Rentang layanan:</label>
                        <div class="col-sm-9">
                            <div id="map" style="height: 500px;width: 100%;" disabled></div>
                        </div>
                    </div>
                    @}
 
                    @if(language==1){
                    <div class="form-group">
                        <label class="col-sm-3 control-label">已添加经营业务</label>
                        <div class="col-sm-9">
                            <div style="height: 200px; border: 1px solid #e5e6e7;overflow-y: auto;">
                                <table class="table table-striped table-bordered table-hover table-condensed">
                                    <thead>
                                    <tr>
                                        <th style="width: 300px;">添加时间</th>
                                        <th style="width: 300px;">经营业务</th>
                                        <th style="width: 300px;">排序</th>
                                    </tr>
                                    </thead>
                                    <tbody id="coun">
                                    @for(obj in businessList){
                                    <tr class="timeClass">
                                        <td>
                                            <input type="hidden" id="busId" name="busId" value="${obj.id}">
                                            <input type="hidden" id="time" name="time" value="${obj.insertTimeStr}">${obj.insertTimeStr}</td>
                                        <td><input type="hidden" id="type" name="type" value="${obj.businessTypeStr}">${obj.businessTypeStr}</td>
                                        <td><input type="hidden" id="sort" name="sort" value="${obj.sort}">${obj.sort}</td>
                                    </tr>
                                    @}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    @}
                    @if(language==2){
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Business has been added</label>
                        <div class="col-sm-9">
                            <div style="height: 200px; border: 1px solid #e5e6e7;overflow-y: auto;">
                                <table class="table table-striped table-bordered table-hover table-condensed">
                                    <thead>
                                    <tr>
                                        <th style="width: 300px;">add time</th>
                                        <th style="width: 300px;">carry on business</th>
                                        <th style="width: 300px;">sort</th>
                                    </tr>
                                    </thead>
                                    <tbody id="coun">
                                    @for(obj in businessList){
                                    <tr class="timeClass">
                                        <td>
                                            <input type="hidden" id="busId" name="busId" value="${obj.id}">
                                            <input type="hidden" id="time" name="time" value="${obj.insertTimeStr}">${obj.insertTimeStr}</td>
                                        <td><input type="hidden" id="type" name="type" value="${obj.businessTypeStr}">${obj.businessTypeStr}</td>
                                        <td><input type="hidden" id="sort" name="sort" value="${obj.sort}">${obj.sort}</td>
                                    </tr>
                                    @}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    @}
                    @if(language==3){
                    <div class="form-group">
                        <label class="col-sm-3 control-label">Bisnis ditambah</label>
                        <div class="col-sm-9">
                            <div style="height: 200px; border: 1px solid #e5e6e7;overflow-y: auto;">
                                <table class="table table-striped table-bordered table-hover table-condensed">
                                    <thead>
                                    <tr>
                                        <th style="width: 300px;">Tambah Waktu</th>
                                        <th style="width: 300px;">Bisnis operasi</th>
                                        <th style="width: 300px;">Sort</th>
                                    </tr>
                                    </thead>
                                    <tbody id="coun">
                                    @for(obj in businessList){
                                    <tr class="timeClass">
                                        <td>
                                            <input type="hidden" id="busId" name="busId" value="${obj.id}">
                                            <input type="hidden" id="time" name="time" value="${obj.insertTimeStr}">${obj.insertTimeStr}</td>
                                        <td><input type="hidden" id="type" name="type" value="${obj.businessTypeStr}">${obj.businessTypeStr}</td>
                                        <td><input type="hidden" id="sort" name="sort" value="${obj.sort}">${obj.sort}</td>
                                    </tr>
                                    @}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    @}
 
                    @if(language==1){
                    <div class="row">
                        <div class="col-sm-10">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">处理意见:</label>
                                <div class="col-sm-9"  style="display: flex;align-items: center;">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio" id="state2" value="3" name="state" checked="" >
                                        <label for="state2"> 同意 </label>
                                    </div>
                                    <div class="radio radio-success radio-inline">
                                        <input type="radio" id="state3" value="2" name="state" >
                                        <label for="state3"> 拒绝 </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">填写备注:</label>
                                <div class="col-sm-9">
                                    <textarea type="text/plain" class="form-control" name="remark" id="remark" style="width:100%;height:150px;"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    @}
                    @if(language==2){
                    <div class="row">
                        <div class="col-sm-10">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">Handling opinions:</label>
                                <div class="col-sm-9"  style="display: flex;align-items: center;">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio" id="state2" value="3" name="state" checked="" >
                                        <label for="state2"> agree with </label>
                                    </div>
                                    <div class="radio radio-success radio-inline">
                                        <input type="radio" id="state3" value="2" name="state" >
                                        <label for="state3"> refuse </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">Fill in remarks:</label>
                                <div class="col-sm-9">
                                    <textarea type="text/plain" class="form-control" name="remark" id="remark" style="width:100%;height:150px;"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    @}
                    @if(language==3){
                    <div class="row">
                        <div class="col-sm-10">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">Mentangani pendapat:</label>
                                <div class="col-sm-9"  style="display: flex;align-items: center;">
                                    <div class="radio radio-info radio-inline">
                                        <input type="radio" id="state2" value="3" name="state" checked="" >
                                        <label for="state2"> setuju dengan </label>
                                    </div>
                                    <div class="radio radio-success radio-inline">
                                        <input type="radio" id="state3" value="2" name="state" >
                                        <label for="state3"> menolak </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">Isi komentar:</label>
                                <div class="col-sm-9">
                                    <textarea type="text/plain" class="form-control" name="remark" id="remark" style="width:100%;height:150px;"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    @}
 
 
                </div>
            </div>
 
            <div class="row btn-group-m-t">
                <div class="col-sm-10 col-sm-offset-5">
                    @if(language==1){
                    <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="TOpenCityInfoDlg.immediately()"/>
                    <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="TOpenCityInfoDlg.close()"/>
                    @}
                    @if(language==2){
                    <#button btnCss="info" name="Submit" id="ensure" icon="fa-check" clickFun="TOpenCityInfoDlg.immediately()"/>
                    <#button btnCss="danger" name="Cancel" id="cancel" icon="fa-eraser" clickFun="TOpenCityInfoDlg.close()"/>
                    @}
                    @if(language==3){
                    <#button btnCss="info" name="Kirim" id="ensure" icon="fa-check" clickFun="TOpenCityInfoDlg.immediately()"/>
                    <#button btnCss="danger" name="Batal" id="cancel" icon="fa-eraser" clickFun="TOpenCityInfoDlg.close()"/>
                    @}
 
                </div>
            </div>
        </div>
 
    </div>
</div>
<script async src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCnvS7Xm3utDjc2fdd5Gvk5E1-bavcrzAA&libraries=drawing&callback=initMap"></script>
<script src="${ctxPath}/modular/system/tOpenCity/tOpenCity_info.js"></script>
<script type="text/javascript">
    // This example requires the Drawing library. Include the libraries=drawing
    // parameter when you first load the API. For example:
    // <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=drawing">
    const content$ = $('#content').val();
    let content_latLng = (null == content$ || '' == content$) ? [] : JSON.parse(content$);
    let drawingManager = null;
    let map;
    function initMap() {
        map = new google.maps.Map(document.getElementById("map"), {
            center: { lat: -6.9174639, lng: 107.6191228 },
            zoom: 8,
        });
        drawingManager = new google.maps.drawing.DrawingManager({
            drawingMode: google.maps.drawing.OverlayType.MARKER,
            drawingControl: true,
            drawingControlOptions: {
                position: google.maps.ControlPosition.TOP_CENTER,
                drawingModes: [
                    google.maps.drawing.OverlayType.POLYGON,
                    // google.maps.drawing.OverlayType.CIRCLE,
                ],
            },
            circleOptions: {
                fillColor: "#8ab4f8",
                fillOpacity: 0.5,
                strokeWeight: 1,
                clickable: false,
                draggable: true,
                editable: true,
                zIndex: 1,
            },
            polygonOptions: {
                fillColor: "#8ab4f8",
                fillOpacity: 0.5,
                strokeWeight: 1,
                clickable: false,
                draggable: true,
                editable: true,
                zIndex: 1,
            }
        });
 
        drawingManager.setMap(map);
        drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)
        //圆形完成监听
        google.maps.event.addListener(drawingManager, 'circlecomplete', function(circle) {
            circle.id = Date.now();
            let center = circle.getCenter();//中心点坐标
            let lat = center.lat();//纬度
            let lng = center.lng();//经度
            let radius = circle.getRadius();//半径(米)
            content_latLng.push({
                id: circle.id,
                type: 'circle',
                center: lat + "," + lng,
                radius: radius
            })
 
            //圆形半径修改监听
            google.maps.event.addListener(circle, 'radius_changed', function() {
                edit_circle(circle);
            });
            //圆形中心修改监听
            google.maps.event.addListener(circle, 'center_changed', function() {
                edit_circle(circle);
            });
        });
 
        //多边形完成监听
        google.maps.event.addListener(drawingManager, 'polygoncomplete', function(polygon) {
            polygon.id = Date.now();
            polygon.getPaths().forEach(function (element, index) {
                let arr = [];
                for(let i in element.g){
                    let lat = element.g[i].lat();//纬度
                    let lng = element.g[i].lng();//经度
                    arr.push(lat + "," + lng)
                }
                content_latLng.push({
                    id: polygon.id,
                    type: 'polygon',
                    center: arr,
                })
            });
            //多边形修改监听
            polygon.getPath().addListener("insert_at", function() {
                edit_polygon(polygon);
            })
            //多边形修改监听
            polygon.getPath().addListener("remove_at", function() {
                edit_polygon(polygon);
            })
            //多边形修改监听
            polygon.getPath().addListener("set_at", function() {
                edit_polygon(polygon);
            })
        });
 
 
 
        for(let i in content_latLng){
            let fence = content_latLng[i];
            if(fence.type == 'circle'){
                let latlng = fence.center;
                let lat = parseFloat(latlng.split(",")[0]);
                let lng = parseFloat(latlng.split(",")[1]);
                let radius = fence.radius;
                const cityCircle = new google.maps.Circle({
                    id: fence.id,
                    fillColor: "#8ab4f8",
                    fillOpacity: 0.5,
                    strokeWeight: 1,
                    clickable: false,
                    draggable: true,
                    editable: true,
                    zIndex: 1,
                    center: new google.maps.LatLng(lat, lng),
                    radius: radius
                });
                cityCircle.setMap(map);
 
                //圆形半径修改监听
                google.maps.event.addListener(cityCircle, 'radius_changed', function() {
                    edit_circle(cityCircle);
                });
                //圆形中心修改监听
                google.maps.event.addListener(cityCircle, 'center_changed', function() {
                    edit_circle(cityCircle);
                });
            }
            if(fence.type == 'polygon'){
                let paths = [];
                for(let j in fence.center){
                    paths.push({
                        lat: parseFloat(fence.center[j].split(",")[0]),
                        lng: parseFloat(fence.center[j].split(",")[1])
                    });
                }
                const bermudaTriangle  = new google.maps.Polygon({
                    id: fence.id,
                    fillColor: "#8ab4f8",
                    fillOpacity: 0.5,
                    strokeWeight: 1,
                    clickable: false,
                    draggable: true,
                    editable: true,
                    zIndex: 1,
                    paths: paths
                });
 
                bermudaTriangle .setMap(map);
                //多边形修改监听
                bermudaTriangle.getPath().addListener("insert_at", function() {
                    edit_polygon(bermudaTriangle);
                })
                //多边形修改监听
                bermudaTriangle.getPath().addListener("remove_at", function() {
                    edit_polygon(bermudaTriangle);
                })
                //多边形修改监听
                bermudaTriangle.getPath().addListener("set_at", function() {
                    edit_polygon(bermudaTriangle);
                })
 
            }
        }
 
    };
 
 
 
    window.initMap = initMap;
 
 
    $('input[name="patternType"]').on('click', function () {
        let patternType_value = $(this).val();
        if(patternType_value == 1){
            drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)
        }else{
            drawingManager.setDrawingMode(google.maps.drawing.OverlayType.CIRCLE)
        }
    })
 
 
    function edit_polygon(polygon) {
        for(let i in content_latLng){
            let fence = content_latLng[i];
            if(fence.type == 'polygon'){
                if(fence.id == polygon.id){
                    polygon.getPaths().forEach(function (element, index) {
                        let arr = [];
                        for(let i in element.g){
                            let lat = element.g[i].lat();//纬度
                            let lng = element.g[i].lng();//经度
                            arr.push(lat + "," + lng)
                        }
                        content_latLng[i] = {
                            id: polygon.id,
                            type: 'polygon',
                            center: arr,
                        }
                    });
                }
            }
        }
    }
 
 
    function edit_circle(circle) {
        for(let i in content_latLng){
            let fence = content_latLng[i];
            if(fence.type == 'circle'){
                if(fence.id == circle.id){
                    let center = circle.getCenter();//中心点坐标
                    let lat = center.lat();//纬度
                    let lng = center.lng();//经度
                    let radius = circle.getRadius();//半径(米)
                    content_latLng[i] = {
                        id: circle.id,
                        type: 'circle',
                        center: lat + "," + lng,
                        radius: radius
                    }
                }
            }
        }
    }
</script>
@}