File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
python/jupyter_leaflet/src/layers Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,29 @@ export class LeafletMarkerClusterView extends LeafletLayerView {
7171
7272 create_obj ( ) {
7373 const options = this . get_options ( ) ;
74- this . obj = L . markerClusterGroup ( options ) ;
74+
75+ // Intercept the creation of the cluster group to disable leaflet.pm
76+ // (so that GeomanDrawControl will not be able to edit it)
77+ const clusterGroup = L . markerClusterGroup ( options ) ;
78+ const originalAddLayer = ( clusterGroup as any ) . _featureGroup . addLayer ;
79+ ( clusterGroup as any ) . _featureGroup . addLayer = function ( layer : L . Layer ) {
80+ if (
81+ // A cluster "bubble" is a marker with a child count
82+ layer instanceof L . Marker &&
83+ typeof ( layer as any ) . getChildCount === 'function'
84+ ) {
85+ ( layer as any ) . pmIgnore = true ;
86+ // Disable the leaflet.pm functionality for the cluster bubble
87+ if ( ( layer as any ) . pm ) {
88+ ( layer as any ) . pm . disable ( ) ;
89+ delete ( layer as any ) . pm ;
90+ }
91+ }
92+
93+ return originalAddLayer . call ( this , layer ) ;
94+ } ;
95+ this . obj = clusterGroup ;
96+
7597 this . marker_views = new ViewList (
7698 this . add_layer_model ,
7799 this . remove_layer_view ,
You can’t perform that action at this time.
0 commit comments