LoginSignup
0
2

More than 5 years have passed since last update.

leafletプラグイン > leaflet-fusesearch

Posted at

あいまい検索Fuse.jsをLeafletで使えるようにするプラグイン

naomap/leaflet-fusesearch

image

install fuse.js

$ npm install fuse.js

    <link rel="stylesheet" href="./node_modules/leaflet/dist/leaflet.css" />
    <script src="./node_modules/leaflet/dist/leaflet.js"></script>

    <script src="./node_modules/fuse.js/dist/fuse.min.js"></script>
    <link rel="stylesheet" href="./leaflet-fusesearch/src/leaflet.fusesearch.css" />
    <script src="./leaflet-fusesearch/src/leaflet.fusesearch.js"></script>
    <script src="./js/data.js"></script>
    <link rel="stylesheet" href="./css/leaflet.infopane.css" />

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js"></script>

JS

    var map = L.map('map');
    map.setView([51.505, -0.09], 13);
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);


    var searchCtrl = L.control.fuseSearch()
    searchCtrl.addTo(map);
    map.addControl(searchCtrl);

    var props = ['nom_comple', 'libcategor', 'commune'];
    searchCtrl.indexFeatures(jsonData.features, props);
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2