Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The vue2 environment uses mapbox 3.4.0 and lines cannot be displayed #13336

Open
wsl0224 opened this issue Nov 27, 2024 · 0 comments
Open

The vue2 environment uses mapbox 3.4.0 and lines cannot be displayed #13336

wsl0224 opened this issue Nov 27, 2024 · 0 comments

Comments

@wsl0224
Copy link

wsl0224 commented Nov 27, 2024

mapbox-gl-js version:3.4.0

Question

vue2 environment uses mapbox version 3.4.0 When vector graphics are used, markers can be displayed normally, but lines cannot be displayed

handleRenderPath() {
     if (this.map.getLayer('trajectory-line')) {
       this.map.removeLayer('trajectory-line');
     }
     if (this.map.getSource('trajectory')) {
       this.map.removeSource('trajectory');
     }
     // 重新添加源和图层
     this.map.addSource('trajectory', {
       type: 'geojson',
       data: {
         type: 'FeatureCollection',
         geometry: {
           type: 'LineString',
           coordinates: this.pathCoordinates
         }
       }
     });
     this.map.addLayer({
       id: 'trajectory-line',
       type: 'line',
       source: 'trajectory',
       layout: {
         'line-join': 'round',
         'line-cap': 'round'
       },
       paint: {
         'line-color': '#888', // Customize color
         'line-width': 20, // Customize line width
         'line-opacity': 1 // Customize opacity
       }
     });
   },

Links to related documentation

https://docs.mapbox.com/mapbox-gl-js/example/zoomto-linestring/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant