htdocs: Add basic support for the wet stuff

This commit is contained in:
Markus Koch 2021-12-27 11:53:06 +01:00
parent 76570e5369
commit b5fd6aab1f

View File

@ -13,13 +13,14 @@ var streetLabelsRenderer = new L.StreetLabels({
collisionFlg: true, collisionFlg: true,
propertyName: 'name', propertyName: 'name',
showLabelIf: function (layer) { showLabelIf: function (layer) {
switch (layer.geometry.type) { switch (layer.feature.geometry.type) {
case "LineString": case "LineString":
if (mymap.getZoom() <= polyconf_show_street_names) if (mymap.getZoom() <= polyconf_show_street_names)
return false; return false;
break; break;
case "Polygon": case "Polygon":
if (mymap.getZoom() > polyconf_show_street_names) if ((mymap.getZoom() > polyconf_show_street_names) &&
(layer.myName != "Oceans"))
return false; return false;
break; break;
default: default:
@ -48,7 +49,12 @@ streetLabelsRenderer._getCollisionFlag = function (layer) {
streetLabelsRenderer._getDynamicFontSize = function (layer) { streetLabelsRenderer._getDynamicFontSize = function (layer) {
zoom = mymap.getZoom(); zoom = mymap.getZoom();
switch (layer.geometry.type) { switch (layer.myName) {
case "Oceans":
return size *= 2.0/3;;
break;
default:
switch (layer.feature.geometry.type) {
case "LineString": case "LineString":
if (zoom <= 8) if (zoom <= 8)
return 11; return 11;
@ -61,7 +67,7 @@ streetLabelsRenderer._getDynamicFontSize = function (layer) {
size = 30; size = 30;
else else
size = 20; size = 20;
switch (layer.properties.type) { switch (layer.feature.properties.type) {
case "city": case "city":
break; break;
case "town": case "town":
@ -81,6 +87,7 @@ streetLabelsRenderer._getDynamicFontSize = function (layer) {
default: default:
break; break;
} }
}
return 10; return 10;
} }
@ -103,6 +110,10 @@ var style_tech = {
color: "red" color: "red"
}; };
var style_rivers = {
color: "blue"
};
var style_route = { var style_route = {
radius: 8, radius: 8,
fillColor: "#00ff00", fillColor: "#00ff00",
@ -236,6 +247,7 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
break; break;
default: /* else it is a marker with the specified icon */ default: /* else it is a marker with the specified icon */
onEachFeature = function(feature, layer) { onEachFeature = function(feature, layer) {
layer.myName = name;
label = String(feature.properties.name) label = String(feature.properties.name)
layer.bindPopup('<h1><a target="_blank" href="' + wikiurl_base + feature.properties.name + '">' + feature.properties.name + '</a> (' + feature.geometry.coordinates + ')</h1>' + '<p><img style="width:100%" src="' + feature.properties.image + '"></p>' + '<p>' + feature.properties.description + '</p>'); layer.bindPopup('<h1><a target="_blank" href="' + wikiurl_base + feature.properties.name + '">' + feature.properties.name + '</a> (' + feature.geometry.coordinates + ')</h1>' + '<p><img style="width:100%" src="' + feature.properties.image + '"></p>' + '<p>' + feature.properties.description + '</p>');
layer.bindTooltip(label, { layer.bindTooltip(label, {
@ -348,6 +360,8 @@ load_geojson("Trainlines (beta)", "./geojson/trainlines.json", "train", "auto",
load_geojson("TL Access (tech layer)", "./geojson/trainlines_access.json", "train", "auto", 0, style_tech); load_geojson("TL Access (tech layer)", "./geojson/trainlines_access.json", "train", "auto", 0, style_tech);
load_geojson("Railroad Tracks", "./geojson/trains.json", "train", "auto", 0, style_trains); load_geojson("Railroad Tracks", "./geojson/trains.json", "train", "auto", 0, style_trains);
load_geojson("Cities", "./geojson/city_outlines.json", "outline", "auto", 1, style_outlines); load_geojson("Cities", "./geojson/city_outlines.json", "outline", "auto", 1, style_outlines);
load_geojson("Rivers", "./geojson/rivers.json", "street", "auto", 1, style_rivers);
load_geojson("Oceans", "./geojson/oceans.json", "outline", "auto", 1, style_rivers);
function update_geojson() { function update_geojson() {
var xhttp_ps = new XMLHttpRequest(); var xhttp_ps = new XMLHttpRequest();