11<!DOCTYPE html>
22< html lang ="en ">
3- < head >
4- < meta charset ="UTF-8 ">
3+ < head >
4+ < meta charset ="UTF-8 " / >
55 < title > Simple Map</ title >
6- < script src ='https://api.mapbox.com/mapbox-gl-js/v1.9.1/mapbox-gl.js '> </ script >
7- < link href ='https://api.mapbox.com/mapbox-gl-js/v1.9.1/mapbox-gl.css ' rel ='stylesheet '/>
8- </ head >
9- < body >
10- < div id ="map " style ="position:absolute; width: 1000px; height: 600px; top: 0;left: 0; "> </ div >
11- < script >
12- fetch ( '/MapboxToken' ) . then ( res => res . text ( ) ) . then ( token => setupMap ( token . trimStart ( ) ) ) ;
13- let map ;
6+ < script src ="https://api.mapbox.com/mapbox-gl-js/v1.9.1/mapbox-gl.js "> </ script >
7+ < link
8+ href ="https://api.mapbox.com/mapbox-gl-js/v1.9.1/mapbox-gl.css "
9+ rel ="stylesheet "
10+ />
11+ </ head >
12+ < body >
13+ < div
14+ id ="map "
15+ style ="position: absolute; width: 1000px; height: 600px; top: 0; left: 0; "
16+ > </ div >
17+ < script >
18+ fetch ( '/MapboxToken' )
19+ . then ( ( res ) => res . text ( ) )
20+ . then ( ( token ) => setupMap ( token . trimStart ( ) ) )
21+ let map
1422
15- function setupMap ( token ) {
16- mapboxgl . accessToken = token ;
23+ function setupMap ( token ) {
24+ mapboxgl . accessToken = token
1725 map = new mapboxgl . Map ( {
18- container : 'map' ,
19- style : 'mapbox://styles/mapbox/light-v9' ,
20- bearing : - 20 ,
21- pitch : 65 ,
22- zoom : 10.4 ,
23- center : [ 16.411462459889663 , 48.19093305465441 ] ,
24- } ) ;
26+ container : 'map' ,
27+ style : 'mapbox://styles/mapbox/light-v9' ,
28+ bearing : - 20 ,
29+ pitch : 65 ,
30+ zoom : 10.4 ,
31+ center : [ 16.411462459889663 , 48.19093305465441 ] ,
32+ } )
2533
2634 map . on ( 'load' , ( ) => {
27- map . addLayer ( {
28- "id" : "population" ,
29- "type" : "fill-extrusion" ,
30- "source" : {
31- "type" : "geojson" ,
32- "data" : "./data/vienna_population.geojson"
33- } ,
34- "paint" : {
35- "fill-extrusion-color" : [
36- "interpolate" ,
37- [ "linear" ] ,
38- [ "*" , 40 , [ "sqrt" , [ "get" , "tot_p" ] ] ] ,
39- 0 ,
40- "#ecda9a" ,
41- 5600 ,
42- "#ee4d5a"
43- ] ,
44- "fill-extrusion-height" : [
45- "*" ,
46- 40 ,
47- [ "sqrt" , [ "get" , "tot_p" ] ]
48- ] ,
49- "fill-extrusion-opacity" : 0.5
50- }
51- } ) ;
52- } ) ;
53- }
54-
55- </ script >
56- </ body >
57- </ html >
35+ map . addLayer ( {
36+ id : 'population' ,
37+ type : 'fill-extrusion' ,
38+ source : {
39+ type : 'geojson' ,
40+ data : '/data/vienna_population.geojson' ,
41+ } ,
42+ paint : {
43+ 'fill-extrusion-color' : [
44+ 'interpolate' ,
45+ [ 'linear' ] ,
46+ [ '*' , 40 , [ 'sqrt' , [ 'get' , 'tot_p' ] ] ] ,
47+ 0 ,
48+ '#ecda9a' ,
49+ 5600 ,
50+ '#ee4d5a' ,
51+ ] ,
52+ 'fill-extrusion-height' : [ '*' , 40 , [ 'sqrt' , [ 'get' , 'tot_p' ] ] ] ,
53+ 'fill-extrusion-opacity' : 0.5 ,
54+ } ,
55+ } )
56+ } )
57+ }
58+ </ script >
59+ </ body >
60+ </ html >
0 commit comments