SHARE
TWEET

Untitled

a guest Feb 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function addData(e) {
  2.     var el = L.control.elevation();
  3.     el.addData(e);
  4.     map.addControl(el);
  5. }
  6.  
  7. function onEachFeature(feature, layer) {
  8.     layer.on ('click', function(e) {
  9.         addData(feature)
  10.     });
  11. }
  12.  
  13.   $.getJSON('data/routes/network=Nwn_Lines.json', function(e) {
  14.     Nwn = L.geoJson(e, {
  15.       style: function(feature, layer) {
  16.         return {color:'#0000FF', weight:3, opacity: 0};
  17.       }, onEachFeature: function(feature, layer) {
  18.         layer.on('mouseover', function() {
  19.           $('#Name').html("Name: "+'<strong>'+layer.feature.properties.name+'</strong>');
  20.           layer.setStyle({color: '#FFFF00', opacity: 1});
  21.         })
  22.         layer.on('mouseout', function() {
  23.           $('#Name').html("Name: ");
  24.           layer.setStyle({opacity: 0});
  25.         })
  26.       }, onEachFeature: onEachFeature
  27.     }).addTo(map);
  28.   });
  29.    
  30. var elevationDisplayed = false;
  31. var currFeature;
  32.  
  33. var el = L.control.elevation();
  34.  
  35. function showElevation(layer) {
  36.   if (elevationDisplayed && (currFeature === layer.feature)) {
  37.     map.removeControl(el);
  38.     elevationDisplayed = false;
  39.     }
  40.   else {
  41.     el.clear();
  42.     if (!elevationDisplayed) el.addTo(map);
  43.     el.addData(layer.feature);
  44.     currFeature = layer.feature;
  45.     elevationDisplayed = true;
  46.   }
  47. };
  48.  
  49. $.getJSON('data/routes/network=Nwn_Lines.json', function(e) {
  50.   Nwn = L.geoJson(e, {
  51.     style: function(feature, layer) {
  52.       return {color:'#0000FF', weight:3, opacity: 0};
  53.     }, onEachFeature: function(feature, layer) {
  54.       layer.on('mouseover', function() {
  55.         $('#Name').html("Name: "+'<strong>'+layer.feature.properties.name+'</strong>');
  56.         layer.setStyle({color: '#FFFF00', opacity: 1});
  57.       })
  58.       layer.on('mouseout', function() {
  59.         $('#Name').html("Name: ");
  60.         layer.setStyle({opacity: 0});
  61.       })
  62.       layer.on ('click', function(e) {
  63.         showElevation(e.target);
  64.       });
  65.     }
  66.   }).addTo(map);
  67. });
  68.    
  69. Error: <path> attribute d: Expected number, "M0,NaNL0.0295626108…".
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top