geojson layer filter function
by grant
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css">
<div id="map">
</div>
<div id="app"></div>
CSS
#map {
position: absolute;
height: 80%;
width: 100%;
}
false-div: {
font-size: small;
}
JavaScript
var myGeoJson = [{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-116.921847,
44.245915
],
[
-116.921986,
44.245442
],
[
-116.922721,
44.245423
]
]
},
"properties": {
"name": "Calf Pasture",
"farm": "Kerner",
"description": "calf pasture fence N end.",
"group": "fence"
}
}, {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-116.90244,
44.23804,
0
],
[
-116.902483,
44.235596,
0
],
[
-116.901496,
44.23661,
0
],
[
-116.90023,
44.23721,
0
],
[
-116.899136,
44.237517,
0
]
]
},
"properties": {
"name": "NE corner K2 pivot",
"farm": "Kerner 2",
"group": "fence",
"description": "Keep the cattle the seeded corner."
}
}, {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-116.915847,
44.243915
],
[
-116.915986,
44.243442
],
[
-116.916721,
44.243423
]
]
},
"properties": {
"name": "Other Pasture",
"farm": "Kerner",
"description": "other pasture fence S end.",
"group": "fence"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates":
[-116.9210, 44.2450]
},
"properties": {
"name": "foodo",
"farm": "Kerner",
"description": "another dog yet.",
"group": "dog"
}
}
]
}];
//console.log(data)
var grayscale = new L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ',
maxZoom: 16
})
var satellite = new ...