mapbox-gl-js

How can I assign the contents of a geojson file to a variable in Javascript?

萝らか妹 提交于 2020-08-09 07:22:31
问题 The code shown already works, but I want to clean it up. It declares a variable called placez which contains information in geojson format for the next part of the code to read and load on a map using filters. However, in reality, the amount of points to be mapped exceeds 50,000 (the example here only shows 2). What I want to know is how I can just load the data coming from a file in the same directory called placesgj.geojson , where the 50,000 data entries will be written in geojson format,

Raycast in Three.js with only a projection matrix

依然范特西╮ 提交于 2020-06-24 11:36:12
问题 I'm rendering some custom layers using Three.js in a Mapbox GL JS page following this example. I'd like to add raycasting to determine which object a user has clicked on. The issue is that I only get a projection matrix from Mapbox, which I use to render the scene: class CustomLayer { type = 'custom'; renderingMode = '3d'; onAdd(map, gl) { this.map = map; this.camera = new THREE.Camera(); this.renderer = new THREE.WebGLRenderer({ canvas: map.getCanvas(), context: gl, antialias: true, }); this

Stylable marker/feature in react-mapbox-gl?

青春壹個敷衍的年華 提交于 2020-06-13 11:31:21
问题 Im using https://github.com/alex3165/react-mapbox-gl My question is how to style the marker or feature component? Feature does not accept children nor style prop. Marker accepts style and children, however it doesnt render anything passed as props and even if I style it with, e.g. {{ background: 'blue' }} it has no any effects on the style. Have I missed something? Thanks 回答1: Marker and Feature are two different components which work in different ways but can both achieve what you are trying

Getting uneven click-detection on 3d-objects on mapbox with raycaster

瘦欲@ 提交于 2020-05-17 06:05:41
问题 I am using raycaster in mapbox with 3d-objects. I need to detect the click on the 3d-object.But When I click on the object I get a empty raycaster.intersectObject (array) sometimes and filled array sometimes, rather it should always have the 3d object that I have clicked. I have a simple map as explained here. I have only added the raycasting part to it to keep it as simple as possible. Here is my code. var longitude, latitude, diff, map, destLongitude, destLatitude, distFrmlast = 0; var

How to get unique feature properties from geojson source in Mapbox GL JS?

倾然丶 夕夏残阳落幕 提交于 2020-05-16 01:35:47
问题 I've defined a mapbox geojson source: map.addSource("places", { type: "geojson", data: "http://example.com/myfile.geojson", }); My geojson source file has this structure: { "type": "FeatureCollection", "features": [{ "type": "Feature", "properties": { "icon": "theatre" }, "geometry": { "type": "Point", "coordinates": [-77.038659, 38.931567] }}, { "type": "Feature", "properties": { "icon": "music" }, "geometry": { "type": "Point", "coordinates": [-77.020945, 38.878241] }}, ...] } I would like

How to get unique feature properties from geojson source in Mapbox GL JS?

痴心易碎 提交于 2020-05-16 01:35:09
问题 I've defined a mapbox geojson source: map.addSource("places", { type: "geojson", data: "http://example.com/myfile.geojson", }); My geojson source file has this structure: { "type": "FeatureCollection", "features": [{ "type": "Feature", "properties": { "icon": "theatre" }, "geometry": { "type": "Point", "coordinates": [-77.038659, 38.931567] }}, { "type": "Feature", "properties": { "icon": "music" }, "geometry": { "type": "Point", "coordinates": [-77.020945, 38.878241] }}, ...] } I would like

Adding custom icons for each feature in feature collection with mapbox-gl-js

假如想象 提交于 2020-05-11 21:18:32
问题 I need to have different custom images for each points in the map using mapbox-gl-js, But I don't find a way to give custom icon for each feature in a feature collection incidentMarkers = { "type": "FeatureCollection" "features": [{ "type": "geojson", "data": { "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ longitude latitude ] } } }, { "type": "geojson", "data": { "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [

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