Leaflet - Diva

From GHER

Revision as of 14:24, 9 March 2017 by Charles (Talk | contribs)
Jump to: navigation, search


legend.onAdd = function (map) {

var div = L.DomUtil.create('div', 'info legend'), grades = [-50, -45, -40, -35, -30, -25, -20, -15], labels = [];

div.innerHTML += 'Mixed layer depth (m)
'

// loop through our density intervals and generate a label with a colored square for each interval for (var i = 0; i < grades.length; i++) { div.innerHTML += ' ' + grades[i] + (grades[i + 1] ? '–' + grades[i + 1] + '
' : '+'); }

return div; };

legend.addTo(map);

function getMoreColor(d) { return d < -50 ? '#d73027' : d < -45 ? '#f46d43' : d < -40 ? '#fdae61' : d < -35 ? '#fee090' : d < -30 ? '#ffffbf' : d < -25 ? '#e0f3f8' : d < -20 ? '#abd9e9' : d < -15 ? '#74add1' : '#4575b4' ; }

function dataStyle(feature) { return { radius: 5, fillColor: getMoreColor(feature.properties.field), weight: 1, opacity: 1, color: 'black', fillOpacity: 0.7 }; }

var contourStyle = { weight: 3, opacity: 1, color : 'grey', fillOpacity: 0. }

var meshStyle = { weight: 0.5, opacity: .5, color : 'grey', fillOpacity: 0. }

var geojsonMarkerOptions = { radius: 5, fillColor: "#ff7800", color: "#000", weight: 1, opacity: 1, fillOpacity: 1 };


function fieldStyle(feature) {

               return {

radius: 5,

                   fillColor: getMoreColor(feature.properties.field),
                   color: getMoreColor(feature.properties.field),
                   weight: 1,
                   opacity: 0.4,
                   fillOpacity: 0.7
               };
           }		
           
           function onEachFeatureee(feature, layer) {

layer.bindPopup(feature.properties.field); };

function onEachFeature(feature, layer) {

var popupContent = "

I started out as a GeoJSON " + feature.geometry.type + ", but now I'm a Leaflet vector!

";

if (feature.properties && feature.properties.field) { popupContent += feature.properties.field; }

layer.bindPopup(popupContent); }


var divamesh = new L.GeoJSON(mesh, {style: meshStyle}); var divafield = new L.GeoJSON(field, {style: fieldStyle}).addTo(map); var divacontours = new L.GeoJSON(contours, {style: contourStyle}).addTo(map);

var divadata = new L.GeoJSON(datapoints, { style: dataStyle, onEachFeature: onEachFeature, pointToLayer: function (feature, latlng) { return L.circleMarker(latlng, {radius: 10, fillOpacity: 0.85}); } }).addTo(map);

var overlayers = { "Contour" : divacontours, "Mesh (L=3)" : divamesh, "Observations" : divadata, "Field" : divafield };

L.control.layers(baseMaps, overlayers).addTo(map);

</script>

</body> </html>

Personal tools