File tree Expand file tree Collapse file tree 2 files changed +19
-20
lines changed
Expand file tree Collapse file tree 2 files changed +19
-20
lines changed Original file line number Diff line number Diff line change 1- let apis = {
1+ const osmApiUrl = new URLSearchParams ( location . search ) . get ( 'osmApiUrl' ) || 'https://api.openstreetmap.org/api/0.6' ;
2+ const apis = {
23 bounding : {
3- api :'https://api.openstreetmap.org/api/0.6 /map?bbox=',
4+ api : osmApiUrl + ' /map?bbox=',
45 url : ( left , bottom , right , top ) => {
56 return apis . bounding . api + left + ',' + bottom + ',' + right + ',' + top ;
67 } ,
78 } ,
89 getRelation : {
9- api :'https://api.openstreetmap.org/api/0.6 /relation/',
10- parameters :'/full' ,
10+ api : osmApiUrl + ' /relation/',
11+ parameters : '/full' ,
1112 url : ( relationId ) => {
1213 return apis . getRelation . api + relationId + apis . getRelation . parameters ;
1314 } ,
1415 } ,
1516 getWay : {
16- api :'https://api.openstreetmap.org/api/0.6 /way/',
17- parameters :'/full' ,
17+ api : osmApiUrl + ' /way/',
18+ parameters : '/full' ,
1819 url : ( wayId ) => {
1920 return apis . getWay . api + wayId + apis . getWay . parameters ;
2021 } ,
Original file line number Diff line number Diff line change @@ -40,20 +40,18 @@ function init() {
4040
4141 window . printError = printError ;
4242
43- if ( window . location . search . substr ( 1 ) !== null ) {
44- window . location . search . substr ( 1 ) . split ( '&' )
45- . forEach ( function ( item ) {
46- const tmp = item . split ( '=' ) ;
47- if ( tmp [ 0 ] === 'type' ) {
48- type = decodeURIComponent ( tmp [ 1 ] ) ;
49- } else if ( tmp [ 0 ] === 'id' ) {
50- id = decodeURIComponent ( tmp [ 1 ] ) ;
51- } else if ( tmp [ 0 ] === 'info' ) {
52- displayInfo = true ;
53- } else if ( tmp [ 0 ] === 'errorBox' ) {
54- errorBox = true ;
55- }
56- } ) ;
43+ const params = new URLSearchParams ( window . location . search ) ;
44+ if ( params . has ( 'type' ) ) {
45+ type = params . get ( 'type' ) ;
46+ }
47+ if ( params . has ( 'id' ) ) {
48+ id = params . get ( 'id' ) ;
49+ }
50+ if ( params . has ( 'info' ) ) {
51+ displayInfo = true ;
52+ }
53+ if ( params . has ( 'errorBox' ) ) {
54+ errorBox = true ;
5755 }
5856 Building . create ( type , id ) . then ( function ( myObj ) {
5957 mainBuilding = myObj ;
You can’t perform that action at this time.
0 commit comments