mapbox

How to secure the JavaScript API Access Token?

对着背影说爱祢 提交于 2019-11-27 10:07:54
问题 There are numerous online resources which provide JavaScript APIs to access their services. To be more clear, I will base my question on the example of MapBox, but this applies well to many other services in various domains. When someone wants to use such a service in a web application (like the map imagery from MapBox for example), they typically need to Register/Sign Up and obtain an access token to access the service. Now, if I would use the API from the server side - there is no issue: I

Data-driven cluster colour with mapboxgl

限于喜欢 提交于 2019-11-27 08:30:11
问题 I am trying to draw circle which colour depends on a "group" attribute in my geojson. I followed a simple example with these colours: map.addSource("data", { type: "geojson", data: url, cluster: true, clusterMaxZoom: 12, // Max zoom to cluster points on clusterRadius: 20 // Radius of each cluster when clustering points (defaults to 50) }); map.addLayer({ 'id': 'population', 'type': 'circle', 'source': 'data', 'paint': { // make circles larger as the user zooms from z12 to z22 'circle-radius':

Routing between points with MapBox

試著忘記壹切 提交于 2019-11-27 06:20:53
问题 I know that similar questions have been asked here before but none of them really answered my question and I am under pressure to finish my project by a deadline. Basically I am writing an application that will show online and offline maps. I am currently using MapBox SDK for the viewing of both offline and online maps, however, MapBox does not currently offer a routing solution. So I am looking for a way to do it. The main problem seems to be that there isn't just one SDK that will offer

Zoom to fit all markers in Mapbox or Leaflet

青春壹個敷衍的年華 提交于 2019-11-26 23:59:39
问题 How do I set view to see all markers on map in Mapbox or Leaflet ? Like Google Maps API does with bounds ? E.g: var latlngbounds = new google.maps.LatLngBounds(); for (var i = 0; i < latlng.length; i++) { latlngbounds.extend(latlng[i]); } map.fitBounds(latlngbounds); 回答1: var group = new L.featureGroup([marker1, marker2, marker3]); map.fitBounds(group.getBounds()); See the documetation for more info. 回答2: The 'Answer' didn't work for me some reasons. So here is what I ended up doing: ////var