javascript - Mapbox Geolocation, how to load into map? -


i have being playing around mapbox , having issues getting geolocation api send data map , update it.

this got right now:

  mapboxgl.accesstoken = 'token-here';   var map = new mapboxgl.map({          container: 'map', // container id          style: 'mapbox://styles/mapbox/streets-v9',           center: [-0.968539, 54.562917],          zoom: 9    });    map.on('style.load', function() {       map.addsource("mymap", {              "type": "geojson",              "data": "https://api.mapbox.com/geocoding/v5/mapbox.places/uk_address_here.json?country=gb&types=address&autocomplete=true&access_token=toekn"       });        map.addlayer({           'id': 'test1',           'type': 'line',           'source': 'mymap',           'interactive': true       });  }); 

the answer may lie how encoding uk_address_here.

https://api.mapbox.com/geocoding/v5/mapbox.places/uk_address_here.json


the request format mapbox geocding api requires since {query} parameter can contain value, should url-encoded.

that means simple geocode request 10 downing street, westminster must encoded using encodeuricomponent 10%20downing%20street%2c%20westminster.

try , verify request proper.

curl https://api.tiles.mapbox.com/geocoding/v5/mapbox.places/10%20downing%20street%2c%20london.json?access_token=${mapbox_access_token} 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -