@@ -18,12 +18,12 @@ insertCss(
18
18
19
19
var MapboxGeocoder = require ( '../' ) ;
20
20
21
- // var mapDiv = document.body.appendChild(document.createElement('div'));
22
- // mapDiv.style.position = 'absolute';
23
- // mapDiv.style.top = 0;
24
- // mapDiv.style.right = 0;
25
- // mapDiv.style.left = 0;
26
- // mapDiv.style.bottom = 0;
21
+ var mapDiv = document . body . appendChild ( document . createElement ( 'div' ) ) ;
22
+ mapDiv . style . position = 'absolute' ;
23
+ mapDiv . style . top = 0 ;
24
+ mapDiv . style . right = 0 ;
25
+ mapDiv . style . left = 0 ;
26
+ mapDiv . style . bottom = 0 ;
27
27
28
28
var notMapDiv = document . body . appendChild ( document . createElement ( 'div' ) ) ;
29
29
notMapDiv . style . position = 'absolute' ;
@@ -35,12 +35,12 @@ notMapDiv.style.backgroundColor = 'red';
35
35
36
36
notMapDiv . classList . add ( "notAMap" ) ;
37
37
38
- // var map = new mapboxgl.Map({
39
- // container: mapDiv,
40
- // style: 'mapbox://styles/mapbox/streets-v9',
41
- // center: [-79.4512, 43.6568],
42
- // zoom: 13
43
- // });
38
+ var map = new mapboxgl . Map ( {
39
+ container : mapDiv ,
40
+ style : 'mapbox://styles/mapbox/streets-v9' ,
41
+ center : [ - 79.4512 , 43.6568 ] ,
42
+ zoom : 13
43
+ } ) ;
44
44
45
45
var coordinatesGeocoder = function ( query ) {
46
46
var matches = query . match ( / ^ [ ] * ( - ? \d + \. ? \d * ) [ , ] + ( - ? \d + \. ? \d * ) [ ] * $ / ) ;
@@ -97,27 +97,27 @@ window.geocoder = geocoder;
97
97
var button = document . createElement ( 'button' ) ;
98
98
button . textContent = 'click me' ;
99
99
100
- // var removeBtn = document.body.appendChild(document.createElement('button'));
101
- // removeBtn.style.position = 'absolute';
102
- // removeBtn.style.zIndex = 10;
103
- // removeBtn.style.top = '10px';
104
- // removeBtn.style.left = '10px';
105
- // removeBtn.textContent = 'Remove geocoder control';
106
-
107
- // map
108
- // .getContainer()
109
- // .querySelector('.mapboxgl-ctrl-bottom-left')
110
- // .appendChild(button);
111
- // // map.addControl(geocoder);
112
-
113
- // map.on('load', function() {
114
- // button.addEventListener('click', function() {
115
- // geocoder.query('Montreal Quebec');
116
- // });
117
- // removeBtn.addEventListener('click', function() {
118
- // map.removeControl(geocoder);
119
- // });
120
- // });
100
+ var removeBtn = document . body . appendChild ( document . createElement ( 'button' ) ) ;
101
+ removeBtn . style . position = 'absolute' ;
102
+ removeBtn . style . zIndex = 10 ;
103
+ removeBtn . style . top = '10px' ;
104
+ removeBtn . style . left = '10px' ;
105
+ removeBtn . textContent = 'Remove geocoder control' ;
106
+
107
+ map
108
+ . getContainer ( )
109
+ . querySelector ( '.mapboxgl-ctrl-bottom-left' )
110
+ . appendChild ( button ) ;
111
+ // map.addControl(geocoder);
112
+
113
+ map . on ( 'load' , function ( ) {
114
+ button . addEventListener ( 'click' , function ( ) {
115
+ geocoder . query ( 'Montreal Quebec' ) ;
116
+ } ) ;
117
+ removeBtn . addEventListener ( 'click' , function ( ) {
118
+ map . removeControl ( geocoder ) ;
119
+ } ) ;
120
+ } ) ;
121
121
122
122
geocoder . on ( 'results' , function ( e ) {
123
123
console . log ( 'results: ' , e . features ) ;
0 commit comments