Comments (5)
Can you please post some code? Or a codesandbox demonstrating the issue you are experiencing? This does not sound like an issue with this plugin rather than a question about how to code something. Please post a minimal reproducible example.
from react-esri-leaflet.
import React, { useEffect } from "react";
import L from "leaflet";
import 'leaflet/dist/leaflet.css';
import { MapContainer, TileLayer, GeoJSON, useMap} from "react-leaflet";
import axios from "axios";
import { FeatureLayer } from "react-esri-leaflet";
const MyData = () => {
const [data, setData] = React.useState();
const map = useMap();
useEffect(() => {
const getData = async () => {
const response = await axios.get(
"https://gist.githubusercontent.com/UmairMughal901/486a7f64d1325ea8cb0c4f91925c5d85/raw/521f91aedb0b08b02ab7746e332041e31dc72360/map.geojson"
);
setData(response.data);
};
getData();
}, []);
if (data) {
// These next 3 lines purely for debuggins:
const geojsonObject = L.geoJSON(data);
//map.fitBounds(geojsonObject.getBounds());
//console.log(geojsonObject);
// end debugging
return <GeoJSON data={data} />;
} else {
return null;
}
};
const Map = (props) => {
return (
<MapContainer
doubleClickZoom={true}
id="mapId"
zoom={5}
center={[32, 71]}
>
<MyData />
<FeatureLayer url={'http://202.166.167.121:6080/arcgis/rest/services/Punjab/PB_irisportal_pg31_v_02112017/MapServer/12'}
eventHandlers={{
load: () => console.log('featurelayer loaded')
}}
/>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
maxZoom='13'
/>
</MapContainer>
);
};
export default Map;
from react-esri-leaflet.
Thank you for your prompt reply. I make a sandbox example and share it.
from react-esri-leaflet.
https://codesandbox.io/s/table-of-content-ldvwh?file=/src/Map.js
from react-esri-leaflet.
I don't see any checkbox in your example. You created a sandbox but I am still very unclear on what you are trying to accomplish.
Ultimately, adding and removing a layer based on the checked
status of some input field is the same as conditionally rendering any react component based on a state variable. That is not specific to react-esri-leaflet, but to react-leaflet in general. As this is not an issue with this plugin, I am closing this issue. I recommend you post a question on stack overflow. If you do that, post a link here and I can take a look and attempt an answer there on SO.
from react-esri-leaflet.
Related Issues (17)
- Warning about Identify in esri-leaflet creating multiple callback scripts HOT 3
- this.leafletElement is undefined (v2) HOT 8
- Add support to new flag ignoreDeprecationWarning from esri-leaflet > v3.0.2 HOT 8
- Issue with refs + Typescript (TiledMapLayer) HOT 5
- Can't change basemap layer HOT 2
- BasemapLayer is deprecated HOT 1
- Uncaught ReferenceError: y is not defined (Production) HOT 1
- "Suggestions" show different results than the actual "results" HOT 1
- Geosearch Multiple Providers of same type ? HOT 4
- Example of WMTS ? HOT 1
- VectorTileLayer not working with vite project HOT 4
- Could not resolve dependency: [ react-esri-leaflet , esri-leaflet , esri-leaflet-vector ] HOT 8
- "build" command does not transpile output HOT 3
- Question: how to use setWhere or equivalent with a FeatureLayer❓ HOT 8
- Add Support for Esri Leaflet Renderers HOT 8
- Cannot useRef with functional components HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-esri-leaflet.