alex3165 / react-mapbox-gl

A React binding of mapbox-gl-js
http://alex3165.github.io/react-mapbox-gl/
MIT License
1.93k stars 535 forks source link

multiple layers not suppoted? #883

Open JesseySt-Studyworks opened 4 years ago

JesseySt-Studyworks commented 4 years ago

Quick question, for my project, I want to add different kinds of markers. This can be done with the Marker component but iI saw in the documentation, that the layer and feature components are way more performance efficient. However, if I add a second component, it overrides the first layer.

My map component is structured like this:

<Map
 ref={mapboxMap}
 Id="mapbox"              
 accessToken= accessToken
 style="mapbox://styles/mapbox/light-v10"
 containerStyle={{
  height: "75vh",
  width: "100%",
  minWidth: "75vh",
 }}
 className="map"
 center={focusPoint}
 zoom={[zoom]}
>
  <Layer type="symbol" layout={{ "icon-image": "harbor-15" }}>
    <Feature coordinates={[-0.13235092163085938,51.518250335096376]}/>
   </Layer>
   <Layer type="symbol" layout={{ "icon-image": "roadblock-15" }}>
      <Feature coordinates={[-0.13240092163085938,51.513450335096376]}/>
   </Layer>
</Map>

is there a way to still use Layers? this is just an example, both layers will be full of Markers.

solarstar101 commented 4 years ago

you can implement 2 layers try setting 2 different id tags for each layer element.