mapbox-gl

Mapbox-GL setStyle removes layers

为君一笑 提交于 2020-03-17 06:55:50
问题 I'm building a mapping web application using Mapbox-GL. It has a lot of cool features. I've set up the buttons to switch base maps (ie. satellite, terrain, etc) following the example on the Mapbox website. The problem that I am having is that when I change the style it removes my polygons that are loaded as layers and reloads the map. I load in polygons from a Mongo database as layers based on user queries. I want to be able to change the base map and keep those layers. Is there a way to

use mapbox geocoding in react native

旧时模样 提交于 2020-01-16 08:41:50
问题 I need to use forward geocoding and reverse geocoding for mapbox in react-native. is there any package or solution to do it? 回答1: I found one solutions to do that: it would be here, call API directly: https://docs.mapbox.com/api/search/#geocoding 来源: https://stackoverflow.com/questions/59678043/use-mapbox-geocoding-in-react-native

Mapbox Web GL JS - querySourceFeatures() function with vector tile source

强颜欢笑 提交于 2020-01-13 06:31:26
问题 I've got a vector tileset on Mapbox that I created by uploading a geojson file comprising polygons representing particular suburbs in Victoria, Australia. My vector tileset has three properties - suburb, state, postcode - corresponding to the feature properties in the geojson. I can also successfully query those properties via the Mapbox web gl js library to get an accurate map. For example I've got a map working that shows a popup when I click a highlighted polygon, and the popup correctly

Polygon Selection change color

冷暖自知 提交于 2020-01-05 05:34:05
问题 is there any way to change the default color of the mapbox draw tool, i'd like to draw polygons with green color instead of the default orange. something like var draw = new MapboxDraw({ displayControlsDefault: false, controls: { polygon: true, trash: true } properties: { color: green } }); map.addControl(draw); 回答1: You can add a styles parameter like this: const mapDraw = new MapboxDraw({ styles: [ // ACTIVE (being drawn) // polygon fill { "id": "gl-draw-polygon-fill", "type": "fill",

iOS - MapBox pass custom info through annotation

霸气de小男生 提交于 2020-01-04 05:23:04
问题 I am using MapBox and I would like to pass custom information through an AnnotationPoint. I need that information to display a custom view when the annotation callout is tapped. The only accessible information is title and subtitle, but that information is displayed in the callout view. This information has to be hidden. How could I achieve this? 回答1: You want to subclass the annotation class to add your own properties. Then, in the delegate methods, you can check the type of the annotations

Render a FeatureCollection from a GeoJSON file with multiple types in Mapbox-GL-JS

梦想的初衷 提交于 2019-12-25 06:58:24
问题 We are currently loading layers into mapbox GL from geojson data. If our geojson has a feature collection that contains points and polygons, there does not seem to be a way to have mapbox gl show both because of how you need to set the type of layer. Is there a way to have multiple types for a layer? It seems as if it can't handle multiple. map.addLayer({ "id": "route", "type": "line", //THIS SEEMS TO BE THE LIMITATION "source": "route", }); 回答1: You are correct, GL JS cannot handle multiple

Mapbox cluster's data-driven styling

巧了我就是萌 提交于 2019-12-25 03:14:34
问题 When visualizing clusters with Mapbox's GL JS, how can I show clusters as circles which size/colours are proportional to the average of clustered points' property 'Rev', instead of proportional to the point-count property, as my code is doing it now. Is there any way to do this simply, or should I look into other methods? Here's my GeoJson file, followed by the HTML/JS code: { "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [-53

Product expression causes features to not render

▼魔方 西西 提交于 2019-12-24 21:52:14
问题 I have a map with linear features that have an offset in the style: "line-offset": { "stops": [ [ 12, 0 ], [ 16, 2 ] ] }, If I try to substitute the value 2 with a product expression, the features fail to render. "line-offset": { "stops": [ [ 12, 0 ], [ 16, ["*", 2, 1] ] ] }, There is no error in the javascript console. I am using the latest version, v0.49.0 . Am I using the expression correctly? 回答1: To use expressions, you would need to change the syntax: "line-offset": [ "interpolate", [

Mapbox.GL: scroll zoom in and out to specific coordinates on custom mapbox map

时间秒杀一切 提交于 2019-12-24 13:50:31
问题 I have embedded a custom mapbox studio map onto my site and set the minZoom and maxZoom coordinates so it only zooms out to a certain zoom level and zooms in to a certain zoom level. BUT when the user zooms back in, the map goes where the user places their mouse pointer, rightly so, BUT I want it to zoom back to it's starting point, not where the user places their mouse pointer. This is the closest example I found, but I don't want the narrative, I want the user to just scroll on the map:

Double on click event with mapbox gl

戏子无情 提交于 2019-12-22 18:11:48
问题 I am redrawing layers on style.load event and removing the layers map.on('style.load', function() { loadByBounds(tempBounds) }); function loadByBounds(b) { if (map.getLayer("cluster-count")) { map.removeLayer("cluster-count"); } ... map.on('click', 'unclustered-point', function(e) { var popup = new mapboxgl.Popup() .setLngLat(e.features[0].geometry.coordinates) .setHTML(text) .addTo(map); })} But how to remove map.on('click') events? As when I click the point the Popup() displays 2 times. And