Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to make flowLines visible on map load #34

Open
facultymatt opened this issue Jul 9, 2014 · 2 comments
Open

Ability to make flowLines visible on map load #34

facultymatt opened this issue Jul 9, 2014 · 2 comments

Comments

@facultymatt
Copy link

When using Leaflet layers you can set them to be initially visible using the visible property. For example:

rain: {
  name: 'Rain',
  type: 'xyz',
  visible: true,
  url: 'http://{s}.tile.openweathermap.org/map/rain/{z}/{x}/{y}.png',
  layerOptions: {
    attribution: 'Map data &copy; <a href="http://openweathermap.org">OpenWeatherMap</a>',
    opacity: 0.5
  }
}

It would be useful to be able to set flowLines to be visible by default in the same way, for example:

displayOptions: {
  ele: {
    visible: true,
    displayName: 'Elevation',
    weight: new L.LinearFunction([0, 3], [15.02968, 20]),
    color: colors //new L.HSLHueFunction([0, 120], [16, -30])
  }
}

this would cause the map to load with the "Elevation" flowLine visible.

@facultymatt
Copy link
Author

I was able to achieve a similar result by using map.addLayer(dataLayer); where dataLayer is the flowLine. The following code works:

var dataLayer = new L.FlowLine(gpx, {
  recordsField: 'wpt',
  locationMode: L.LocationModes.LATLNG,
  latitudeField: 'lat',
  longitudeField: 'lon',
  legendOptions: {
    className: 'legend-line',
    numSegments: 10
  },
  displayOptions: {
    ele: {
      visible: true,
      displayName: 'Elevation',
      weight: new L.LinearFunction([0, 3], [15.02968, 20]),
      color: colors //new L.HSLHueFunction([0, 120], [16, -30])
    }
  },
  layerOptions: {
    opacity: 1.0
  }
});

var layerControl = new L.Control.Layers();
layerControl.addOverlay(dataLayer, 'Flow Line');

// set the layer visible and the box checked. Without this the 
// layer is not visible on map load
map.addLayer(dataLayer); 

layerControl.addTo(map);

@sfairgrieve
Copy link
Contributor

Sorry for the delayed response. Are you referring to passing these layers in to the map constructor, or just creating layers in general? Can you provide a more complete code example of what you want to see? I see your initial code example, but it's not clear where the rain layer is being used - I'm assuming it's being passed to the map constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants