Guest User

Untitled

a guest
Jun 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. var yourGeoJSON = [
  2. { "type": "Feature", "properties": { "id": 2, "elevation": 50 }, "geometry": { "type": "LineString", "coordinates": [ [ 11.836395263671875, 47.75317468890147 ], [ 11.865234375, 47.73193447949174 ] ] } },
  3. { "type": "Feature", "properties": { "id": 1, "elevation": 750 }, "geometry": { "type": "LineString", "coordinates": [ [ 11.865234375,47.73193447949174 ], [ 11.881027221679688, 47.700520033704954 ] ] } },
  4. { "type": "Feature", "properties": { "id": 0, "elevation": 1700 }, "geometry": { "type": "LineString", "coordinates": [ [ 11.881027221679688, 47.700520033704954 ], [ 11.923599243164062, 47.706527200903395 ] ] } },
  5. { "type": "Feature", "properties": { "id": 0, "elevation": 3000 }, "geometry": { "type": "LineString", "coordinates": [ [ 11.923599243164062, 47.706527200903395 ], [ 11.881027221679688, 47.700520033704954 ], ] } }
  6. ];
  7.  
  8. L.geoJson(yourGeoJSON, {
  9. style: function (feature) {
  10. return {
  11. "color": getColor(feature.properties.elevation),
  12. "opacity": 1,
  13. }}
  14. }).addTo(map);
  15.  
  16. function getColor(x) {
  17. return x < 500 ? '#bd0026':
  18. x < 1000 ? '#f03b20':
  19. x < 1500 ? '#fd8d3c':
  20. x < 2000 ? '#fecc5c':
  21. '#ffffb2' ;
  22. };
Add Comment
Please, Sign In to add comment