Giter Site home page Giter Site logo

Comments (3)

bmcbride avatar bmcbride commented on May 29, 2024

Thanks for the suggestion. I'll have to think about this some more. On the one hand, it's great functionality for long lists where you only care about what is in the map view. Sometimes though, it's nice to be able to use the list to navigate the map itself- do a quick search and jump to the location, even if it's not on the map. This is especially true if you trigger geolocation to zoom to the user's location on mobile devices.

from bootleaf.

nilem avatar nilem commented on May 29, 2024

Hi! Just to say that I'm building an app using BootLeaf and I would use such a feature described by dinResita. But you also have a good point : we don't necessarly always want this behavior. It's depend of the context.

from bootleaf.

bmcbride avatar bmcbride commented on May 29, 2024

This could be accomplished by registering a map moveend event to check which points are contained in the current map bounds. I'm still thinking through the best way to include this in the template, but in the meantime, see below for the code to implement this.

map.on("moveend", function (e) {
  $("#feature-list tbody").empty();
  theaters.eachLayer(function (layer) {
    if (map.getBounds().contains(layer.getLatLng())) {
      $("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">' + layer.feature.properties.NAME + '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
    }
  });
  museums.eachLayer(function (layer) {
    if (map.getBounds().contains(layer.getLatLng())) {
      $("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/museum.png"></td><td class="feature-name">' + layer.feature.properties.NAME + '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
    }
  });
  featureList = new List("features", {
    valueNames: ["feature-name"]
  });
  featureList.sort("feature-name", {
    order: "asc"
  });
});

from bootleaf.

Related Issues (20)

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.