Giter Club home page Giter Club logo

lexvlex's People

Watchers

 avatar  avatar

lexvlex's Issues

Answers to Leaflet questions!

These are questions @livienyin had about #3.

[4:40 PM] livien: are "L._______" leaflet functions?

[4:44 PM] livien: what's the difference between including "var" and not including "var" in "Fix variable definition error in style function"?

[5:02 PM] livien: For "function onEachFeature(feature, layer) {
layer.on('click', function(e) {
map.fitBounds(e.target.getBounds());
});
layer.bindPopup(popup(feature));
};" --> Where does the "e" come from and what type of an object is it?

  1. L.__________: I'm not sure how to define this well, but I'll give it a try. (@eeeschwartz should jump in and explain it better!) Leaflet.js is an API that has a bunch of classes in it. One class is a "map": L.map makes a map object. The map has a series of options (which you see in the { } here) and a series of methods you can run on it. L.geoJson and L.tileLayer are also Leaflet objects: you can read more about them in the API doc here.
  2. This change has to do with variable scope. By defining the tractColor in the style function with var, it means that tractColor only has meaning inside of that function. Anything inside of the function knows what it is, but tractColor has no meaning outside of that function. If we decided we needed to access that variable elsewhere in the code, we could leave off the var, making it a "global variable" that can be accessed anywhere.
  3. The layer.on('click') method is an event handler. It says, "When someone clicks on the map, do this function." The Leaflet map class can have quite a few events. The e here represents the event itself -- in this case, click. The callback function that takes e as a parameter is creating an event handler for the click -- it says when you click, fit the bounds of the map to whatever was clicked on. e.target.getBounds() says take the click, find out what was clicked on (the target), and get the bounds of that object. That bounding box is then passed as an argument to the map.fitBounds() method, and the map zooms to that bounding box.

Map changes

[ ] Kill pan
[ ] Kill zoom
[ ] Darken on selected
[ ] Hover with title

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.