File tree Expand file tree Collapse file tree 5 files changed +74
-3
lines changed Expand file tree Collapse file tree 5 files changed +74
-3
lines changed Original file line number Diff line number Diff line change 42
42
- Add ` ignoreEscapeKey ` option.
43
43
- Add ` hideTimepickerNavigation ` option.
44
44
- Add ` circleOptions.strokeEnabled ` and ` circleOptions.strokeWeight ` .
45
+ - Add options ` customAttribution ` and ` customAttributionText ` .
45
46
46
47
## v0.2.0
47
48
Original file line number Diff line number Diff line change 53
53
.editor-link-color {
54
54
color : # 2846a1 ;
55
55
}
56
+
57
+ .gf-form-subgroup {
58
+ margin-bottom : 1rem ;
59
+ }
Original file line number Diff line number Diff line change @@ -336,15 +336,30 @@ <h5>Center and zoom level</h5>
336
336
337
337
< div class ="gf-form-group ">
338
338
< h5 > Appearance</ h5 >
339
+
340
+ <!-- Zoom -->
341
+ < div class ="gf-form-subgroup ">
342
+ < gf-form-switch class ="gf-form " label ="Show Zoom Control " label-class ="width-10 " checked ="ctrl.panel.showZoomControl " on-change ="ctrl.restart() "> </ gf-form-switch >
343
+ < gf-form-switch class ="gf-form " label ="Mouse Wheel Zoom " label-class ="width-10 " checked ="ctrl.panel.mouseWheelZoom " on-change ="ctrl.toggleMouseWheelZoom() "> </ gf-form-switch >
344
+ </ div >
345
+
346
+ <!-- Legend -->
347
+ < div class ="gf-form-subgroup ">
339
348
< gf-form-switch class ="gf-form " label ="Show Legend " label-class ="width-10 " checked ="ctrl.panel.showLegend " on-change ="ctrl.toggleLegend() "> </ gf-form-switch >
340
349
< div class ="gf-form " ng-show ="ctrl.panel.showLegend == true ">
341
350
< label class ="gf-form-label width-10 "> Legend container</ label >
342
351
< input type ="text " class ="input-small gf-form-input max-width-18 " ng-model ="ctrl.panel.legendContainerSelector "
343
352
placeholder =".shared-map-legend " ng-change ="ctrl.restart() " ng-model-onblur />
344
353
</ div >
345
- < gf-form-switch class ="gf-form " label ="Show Zoom Control " label-class ="width-10 " checked ="ctrl.panel.showZoomControl " on-change ="ctrl.restart() "> </ gf-form-switch >
354
+ </ div >
355
+
356
+ <!-- Attribution -->
357
+ < div class ="gf-form-subgroup ">
346
358
< gf-form-switch class ="gf-form " label ="Show Attribution " label-class ="width-10 " checked ="ctrl.panel.showAttribution " on-change ="ctrl.restart() "> </ gf-form-switch >
347
- < gf-form-switch class ="gf-form " label ="Mouse Wheel Zoom " label-class ="width-10 " checked ="ctrl.panel.mouseWheelZoom " on-change ="ctrl.toggleMouseWheelZoom() "> </ gf-form-switch >
359
+ < gf-form-switch class ="gf-form " label ="Custom Attribution " label-class ="width-10 " checked ="ctrl.panel.customAttribution " on-change ="ctrl.toggleCustomAttribution() "> </ gf-form-switch >
360
+ < textarea class ="gf-form input-small gf-form-input width-24 " rows ="5 " ng-show ="ctrl.panel.customAttribution " ng-model ="ctrl.panel.customAttributionText " ng-change ="ctrl.render() "> </ textarea >
361
+ </ div >
362
+
348
363
</ div >
349
364
350
365
< div class ="gf-form-group ">
Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ export default class WorldMap {
80
80
console . info ( 'Drawing circles' ) ;
81
81
this . drawCircles ( ) ;
82
82
83
+ this . drawCustomAttribution ( ) ;
84
+
83
85
setTimeout ( ( ) => {
84
86
this . drawMap ( options ) ;
85
87
} , 1 ) ;
@@ -399,7 +401,9 @@ export default class WorldMap {
399
401
}
400
402
401
403
addCircles ( circles ) {
402
- return ( < any > window ) . L . layerGroup ( circles ) . addTo ( this . map ) ;
404
+ // Todo: Optionally add fixed custom attributions to the circle layer.
405
+ let attribution ;
406
+ return ( < any > window ) . L . layerGroup ( circles , { attribution : attribution } ) . addTo ( this . map ) ;
403
407
}
404
408
405
409
removeCircles ( ) {
@@ -420,4 +424,19 @@ export default class WorldMap {
420
424
}
421
425
this . map . remove ( ) ;
422
426
}
427
+
428
+ drawCustomAttribution ( ) {
429
+ // The operator wants a custom attribution.
430
+ if ( this . ctrl . settings . customAttribution ) {
431
+
432
+ // The custom attribution text.
433
+ const attribution = this . ctrl . settings . customAttributionText ;
434
+
435
+ // Amend the Leaflet map by clearing out and setting the custom attribution text.
436
+ const attributionControl = this . map . attributionControl ;
437
+ attributionControl . _attributions = { } ;
438
+ attributionControl . addAttribution ( attribution ) ;
439
+ }
440
+ }
441
+
423
442
}
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ const panelDefaults = {
39
39
legendContainerSelector : null ,
40
40
showZoomControl : true ,
41
41
showAttribution : true ,
42
+ customAttribution : false ,
43
+ customAttributionText : null ,
42
44
mouseWheelZoom : false ,
43
45
esGeoPoint : null ,
44
46
// Todo: Investigate: Is "Count" a reasonable default here
@@ -507,6 +509,36 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
507
509
this . render ( ) ;
508
510
}
509
511
512
+ toggleCustomAttribution ( ) {
513
+ if ( this . settings . customAttribution ) {
514
+
515
+ const attributionControl = this . map . map . attributionControl ;
516
+
517
+ // When switching on custom attributions and the text is
518
+ // empty yet, use the value which is currently active.
519
+ if ( ! this . panel . customAttributionText ) {
520
+
521
+ // Collect active attributions.
522
+ const entries :Array < any > = [ ] ;
523
+ for ( let key in attributionControl . _attributions ) {
524
+ entries . push ( key ) ;
525
+ }
526
+
527
+ // Store in custom text.
528
+ this . panel . customAttributionText = entries . join ( ', ' ) ;
529
+ }
530
+
531
+ // Clear out builtin attributions.
532
+ attributionControl . _attributions = { } ;
533
+ attributionControl . _update ( ) ;
534
+ this . render ( ) ;
535
+
536
+ } else {
537
+ // The operator wants vanilla attributions again, so let's start over.
538
+ this . restart ( ) ;
539
+ }
540
+ }
541
+
510
542
redrawCircles ( ) {
511
543
this . map . clearCircles ( ) ;
512
544
this . render ( ) ;
You can’t perform that action at this time.
0 commit comments