leafletを鍛える。その34
概要
leafletを鍛えてみた。
turf.jsでvoronoiやってみた。
写真
サンプルコード
var options = {
bbox: [139, 37, 141, 39]
};
var points = turf.randomPoint(100, options);
var voronoiPolygons = turf.voronoi(points, options);
var map = L.map('map').setView([38.0, 140.0], 7);
var mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
out.value = JSON.stringify(voronoiPolygons);
L.geoJson(voronoiPolygons, {
pointToLayer: function(feature, latlng) {
var c = "#f60";
if (feature.properties.rain > 0)
{
c ="#06f";
}
return new L.CircleMarker(latlng, {
radius: 10,
color: "#000",
weight: 1,
fillColor: c,
fillOpacity: 0.75
});
}
}).addTo(map);
var pointStyle = {
pointToLayer: function(feature, latlng) {
return L.circle(latlng);
},
style: {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
}
}
L.geoJson(points, pointStyle).addTo(map);
成果物
var options = {
bbox: [139, 37, 141, 39]
};
var points = turf.randomPoint(100, options);
var voronoiPolygons = turf.voronoi(points, options);
var map = L.map('map').setView([38.0, 140.0], 7);
var mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
out.value = JSON.stringify(voronoiPolygons);
L.geoJson(voronoiPolygons, {
pointToLayer: function(feature, latlng) {
var c = "#f60";
if (feature.properties.rain > 0)
{
c ="#06f";
}
return new L.CircleMarker(latlng, {
radius: 10,
color: "#000",
weight: 1,
fillColor: c,
fillOpacity: 0.75
});
}
}).addTo(map);
var pointStyle = {
pointToLayer: function(feature, latlng) {
return L.circle(latlng);
},
style: {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
}
}
L.geoJson(points, pointStyle).addTo(map);
以上。
Author And Source
この問題について(leafletを鍛える。その34), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/84f8d0b9a940b037e8ce著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .