javascript - Leaflet Omnivore group markers from CSV individually -


I can not group external data with leaflet. With my marker I have a CSV and marker on my map Kept with ubiquitous.

How do I group a marker?

For example: I have 4 markers and assign them the "type" specified in the CSV that this type is called "freebad" how do I group all the markers with the "freebad" type Can I put them in the lairgroup named "Freiband" so that they can be filtered with layer control?

  // MARKERCLUSTER // Wars II var freibad = []; Function Each Layer (Marker) {var ltg = marker.toGeoJSON (); If (ltg.properties.type! = "") {Marker.setIcon (L.CON ({iconUrl: '/ icons /' + ltg.properties.type + '. Png'}))); } If (ltg.properties.img = ""!) {Marker.bindPopup ('& lt; strong & gt;' + ltg.properties.name + '& lt; / strong & gt;' + '& lt; br & Lt; br & gt; & lt; img src = "/ icons" '+ ltg.properties.img +' "& gt; ')} Other {marker.bindPopup ('& Lt; strong & gt;' + ltg.properties.name + '& lt; / strong & gt;' + '
' + ltg.properties.description)}} var point = omnivore .csv ('/ csv / POI.csv', {delimiter: '|'}) .on ('ready', function () {var markers = L. markerClusterGroup ({showCoverageOnHover: false, maxClusterRadius: 50}); markers .addLayer (map); map.addLayer (marker); points.eachLayer (eachLayer);}); // ebenengruppen LAYERGROUPS = {"& lt; strong> Wanderrouten & lt; / strong & gt;: {{" Wanderroute 1 ": wroute1," Wanderroute 2 ": wroute2," Wanderroute 3 ": wroute3," Freibad ": Freibad}}; // basemaps = {"Standard": standardTiles} LayControlMobile = L.cntrol.groupedLayers (basemaps, ebenengruppen, {collapsed}} on TILEMAPS, layerControl = L.control.groupedLayers (basemaps, ebenengruppen); If (Mobile Devices) {map.addControl (Layer ControlMobile); } And {map.addControl (layerControl); }

I just found out how to solve my problem.

Here's what I have done: I have created layer groups for each entry and I have made a line in CSV-file, which has the same name as the level group by checking through the I-statement The layers are added to the groups they are related to. However, this is the best solution I think and not only meaningful, if there are only a few groups ...

  // MARKERCLUSTER // LAYERGROUPS var freibad = new L. LayerGroup (); Var badestelle = new l. Layergroup (); Var convnstig = new L. Layer Group (); Var conuvermatung = new l. Layergroup (); Var conuvermatung = new l. Layergroup (); Var reparatur = New L. Layergroup (); Var radverleih = new l. Layergroup (); // markers each layer function (marker) {var ltg = marker.toGeoJSON (); // Layergropping if (LTG properties. Type == "freebad") {freibad.addLayer (marker); } If (ltg.properties.type == "bainstalele") {badestelle.addLayer (marker); } If (ltg.properties.type == "KanaTIG") {kanueinstieg.addLayer (marker); } If (ltg.properties.type == "Kannukarmittung") {kanuvermietung.addLayer (marker); } If (ltg.properties.type == "reparatur") {reparatur.addLayer (marker); } If (ltg.properties.type == "radverleih") {radverleih.addLayer (marker); } // And Layergropping if (LTG Properties. Type! "") {Marker.set Icon (Lynn (icon: url: / Icons / '+ LTG.Properties. Type' 'SVG'}))); } If (ltg.properties.img! = "") {Marker.bindPopup ('& lt; strong & gt;' + ltg.properties.name + '& lt; / strong & gt;' + '& lt; br & Lt; br & gt; & lt; img src = "/ icons / '+ ltg.properties.img +'" & gt; ')} Other {marker.bindPopup (& lt; '& Lt; strong & gt;' + ltg.properties.name + '& lt; / strong & gt;' + '

' + ltg.properties.description)}} < / Pre>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -