Difference between revisions of "Web Element: Map"
Line 56: | Line 56: | ||
// Add zoom and rotation controls to the map. | // Add zoom and rotation controls to the map. | ||
map.addControl(new mapboxgl.NavigationControl()); | map.addControl(new mapboxgl.NavigationControl()); | ||
+ | |||
+ | // // Create variables to use in getIso() | ||
+ | var urlBase = 'https://api.mapbox.com/isochrone/v1/mapbox/'; | ||
+ | var lon = -77.034; | ||
+ | var lat = 38.899; | ||
+ | var profile = 'cycling'; | ||
+ | var minutes = 10; | ||
+ | |||
+ | // Create a function that sets up the Isochrone API query then makes an Ajax call | ||
+ | function getIso() { | ||
+ | var query = urlBase + profile + '/' + lon + ',' + lat + '?contours_minutes=' + minutes + '&polygons=true&access_token=' + mapboxgl.accessToken; | ||
+ | |||
+ | $.ajax({ | ||
+ | method: 'GET', | ||
+ | url: query | ||
+ | }).done(function(data) { | ||
+ | console.log(data); | ||
+ | }) | ||
+ | }; | ||
+ | |||
+ | // Call the getIso function | ||
+ | // You will remove this later - it's just here so you can see the console.log results in this step | ||
+ | getIso(); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |
hkilter.com by H. K. Ilter is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
© 2020 H. K. Ilter