File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -40,20 +40,10 @@ export class MaptilerGeolocateControl extends GeolocateControl {
4040 }
4141
4242 onAdd ( map : SDKMap | MapMLGL ) {
43- if ( this . removeDefaultDOM ) {
44- this . setupExternalElements ( ) ;
45-
46- return DOMcreate ( "div" ) ;
47- }
43+ this . _map = map as SDKMap ;
4844 return super . onAdd ( map as MapMLGL ) ;
4945 }
5046
51- setupExternalElements = ( ) => {
52- this . externalGeolocateElement ?. addEventListener ( "click" , ( ) =>
53- this . trigger ( ) ,
54- ) ;
55- } ;
56-
5747 /**
5848 * Update the camera location to center on the current position
5949 *
@@ -161,8 +151,14 @@ export class MaptilerGeolocateControl extends GeolocateControl {
161151
162152 this . _map . on ( "move" , this . _onZoom ) ;
163153 }
164-
165- this . _geolocateButton . addEventListener ( "click" , this . trigger . bind ( this ) ) ;
154+ if ( this . externalGeolocateElement ) {
155+ this . externalGeolocateElement . addEventListener (
156+ "click" ,
157+ this . trigger . bind ( this ) ,
158+ ) ;
159+ } else {
160+ this . _geolocateButton . addEventListener ( "click" , this . trigger . bind ( this ) ) ;
161+ }
166162
167163 this . _setup = true ;
168164
You can’t perform that action at this time.
0 commit comments