LoginSignup
0
0

More than 3 years have passed since last update.

leafletを鍛える。その16

Last updated at Posted at 2018-11-02

概要

leafletを鍛えてみた。
マーカークリックで飛んでみた。その2

写真

サンプルコード

var map = L.map('map').setView([38.0748331, 139.4574997], 9);

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



function add_marker() {
    var points = [["P1", 38.077908, 139.542229, "http://jsdo.it/1"], ["P2", 38.075618, 139.642032, "http://jsdo.it/2"], ["P3", 38.0738618, 139.441726, "http://jsdo.it/3"]];
    var marker = [];
    var i;
    for (i = 0; i < points.length; i++) 
    {
            marker[i] = new L.Marker([points[i][1], points[i][2]], {
                title: points[i][0],
                win_url: points[i][3]
            });
            marker[i].addTo(map);
            marker[i].on("click", function() {
                window.open(this.options.win_url);
            });
    };
}
add_marker();

成果物

以上。

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