Skip to content

How can I use colorpicker with react-leaflet? #3

@aequorsolutions

Description

@aequorsolutions

Hello,

I'm using a mix of reac-leaflet and leaflet to make a map using next.js framework and the LayersControl.Basemap is not working to select/deselect a colorpicker layer.

How can I use the leaflet-tilelayer-colorpicker with react-leaflet LayersControl to select from what layer I will pick the color?

function CustomTileLayer (){
...
var colorpicker = L.tileLayer.colorPicker(template, {
layer: 'MODIS_Aqua_L2_Chlorophyll_A',
tileMatrixSet: 'GoogleMapsCompatible_Level7',
maxNativeZoom: 8,
time: "2014-02-12",//dayParameter(),
tileSize: 256,
subdomains: 'abc',
noWrap: true,
continuousWorld: false,
// Prevent Leaflet from retrieving non-existent tiles on the
// borders.
bounds: [
[-85.0511287776, -179.999999975],
[85.0511287776, 179.999999975]
],
}).addTo(map)
...
}

function Map () {
return (
<MapContainer
center={[-24, -44]}
zoom={5}
style={{ width: '100%', height: '600px' }}
preferCanvas={true}
maxBounds={bounds}
maxBoundsViscosity={1.0}
minZoom={3}
maxZoom={7} >

<LayersControl position='topleft'>
  <LayersControl.BaseLayer name="third layer">
      <CustomTileLayer />
  </LayersControl.BaseLayer>
</LayersControl>
) } export default Map

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions