there seem to be a number of questions out there but none have quite answered this for me.
How would one go about taking a custom set of values from a property like latitude, and then assign them to change the marker color for omnivore.CSV data based on that value. Is there a way of calling the pointtoLayers functions within an onready
style section and pointing it to fill colors based on these value tiers?
function getColor(d) {
return d > 42.2 ? '#800026' :
d > 39 ? '#BD0026' :
d > 30 ? '#E31A1C' :
'#FFEDA0'; }
var MarkerOptions = {
radius: 8,
fillColor: getColor(feature.properties.latitude),
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8 };
window.data3 = omnivore.csv('File.csv')
.on('ready', function(layer) {
this.eachLayer(function(markeroptions) {
Answer
Welcome to GIS SE!
Note that the Leaflet omnivore plugin API lets you specify more arguments, including a 3rd argument which is an L.GeoJSON
layer group that you have prepared before hand.
.csv(url, parser_options?, customLayer?)
In particular, you can set its onEachFeature
and/or pointToLayer
option(s), so that when omnivore gets the data, it will go through these options.
See: Passing values for a geojson filter in Leaflet
And this Leaflet omnivore example:
var customLayer = L.geoJson(null, {
// http://leafletjs.com/reference.html#geojson-style
style: function(feature) {
return {
color: '#f00'
};
}
});
// this can be any kind of omnivore layer
var runLayer = omnivore.kml('line.kml', null, customLayer)
No comments:
Post a Comment