0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

leafletを鍛える。Advent Calendar 2019

Day 8

leafletを鍛える。その14

Last updated at Posted at 2018-10-30

#概要

leafletを鍛えてみた。
マウスを追ってみた。

#写真

#サンプルコード

var map = L.map('map').setView([38.3748331, 139.9574997], 12);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var popup = new L.Popup({
    autoPan: false
});

map.on({
    mousemove: mousemove,
    mouseout: mouseout,
});

var closeTooltip;

function mousemove(e) {
    var layer = e.target;
    popup.setLatLng(e.latlng);
    popup.setContent('<div class="marker-title">on</div>' + e.latlng);
    if (!popup._map) popup.openOn(map);
    window.clearTimeout(closeTooltip);
    layer.setStyle({
        weight: 3,
        opacity: 0.3,
        fillOpacity: 0.9
    });
    if (!L.Browser.ie && !L.Browser.opera)
    {
        layer.bringToFront();
    }
}

function mouseout(e) {
    statesLayer.resetStyle(e.target);
    closeTooltip = window.setTimeout(function() {
        map.closePopup();
    }, 100);
}



#成果物

以上。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?