我在弹出窗口中加载切片地图(bing或OSM)。有时,瓷砖丢失/互换了。几天后,一切正常。在我的许多其他Web端,弹出窗口(没有geojson文件)可以正常工作。
您在https://aachen-hat-energie.de/test_ww/window_test.htm上看到一个简单的示例。来自geojson文件的带有标记/ ikon的第一张地图可以。如果单击“ Karte”,您应该在弹出窗口中看到与ikon相同的地图。但是有时候这些图块有时是不正确的,并且标记总是丢失。
我刷新了浏览器(firefox)的缓存,但没有帮助。我可以刷新与ajax一起使用的缓存吗? 为什么我的ikon不见了?
传单和下面的test_windows.js都加载到两个htm文件中:
function show_karte(mittelpunkt, zoom, overlay, typ){
function MarkerStyle (feature,latlng) {
return L.marker(latlng, {icon: L.icon({iconUrl: feature.properties.markerSymbol})}).addTo(map);
};
var scriptTag = document.getElementsByTagName('script');
scriptTag = scriptTag[scriptTag.length - 1];
var div_id = scriptTag.parentNode.id;
var osmLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
var mittelpunkt = [mittelpunkt[1], mittelpunkt[0]]
var map = L.map(div_id,{layers: [osmLayer]}).setView(mittelpunkt, zoom);
$.ajax(overlay).done(function(data) {
var data = JSON.parse(data);
L.geoJson(data,
{pointToLayer: MarkerStyle
});
});
};
function OSMKarte(name,breite,hoehe,gpsLaenge,gpsBreite,zoom,Kartentyp,geojson_datei) {
neuesFenster = window.open("Kartenfenster.htm?"+name+"&"+breite+"&"+hoehe+"&"+gpsLaenge+"&"+gpsBreite+"&"+zoom+"&"+Kartentyp+"&"+geojson_datei,'', "width="+breite+",height="+hoehe+",left=50,top=50, resizable=no, scrollbars=no, border=no");
};
致电htm:
<div id="map1" style="width:583px; height: 350px;">
<script type="text/javascript">show_karte([6.00895041,50.79047758],18,"lieschen.geojson","R");</script>
</div>
<div>
<a href="javascript: OSMKarte('Karte',800,650,6.00895041,50.79047758,18,'R','lieschen.geojson')">Karte</a>
</div>
Kartenfenster.htm生成弹出窗口:
<title></title>
<head>
<script src="../js/Leaflet/leaflet.js" ></script>
<script src="../js/Leaflet/jquery-3.3.1.min.js"></script>
<script src="test_window.js"></script>
<script type="text/javascript">
function getMap() {
var kette = window.location.search.slice(1);
var params = kette.split("&");
var name=params[0];
name = name.replace(/%20/g, " ");
var FBreite=parseInt(params[1]);
var FHoehe=parseInt(params[2]);
var xloc=parseFloat(params[3]);
var yloc=parseFloat(params[4]);
var zStufe=parseInt(params[5]);
var Kartentyp=(params[6]);
var geojson_datei=(params[7]); // kann fehlen
document.getElementsByTagName("title")[0].text =name;
var divElement = document.createElement("div");
var dok = document.getElementsByTagName("body")[0];
dok.appendChild(divElement);
var id_name = document.createAttribute("id");
id_name.nodeValue ="map_popup";
divElement.setAttributeNode(id_name);
var Stil = document.createAttribute("style");
Stil.nodeValue="position:absolute; width:"+FBreite+"px; height:"+FHoehe+"px; left: 0px; top: 0px";
divElement.setAttributeNode(Stil);
var jscript = document.createElement("script");
divElement.appendChild(jscript);
var jtext = document.createAttribute("type");
jtext.nodeValue="text/javascript";
jscript.setAttributeNode(jtext);
var fkt_aufruf = document.createTextNode("show_karte([" + xloc + "," + yloc + "]," + zStufe + ",'" + geojson_datei+ "','" + Kartentyp + "');");
jscript.appendChild(fkt_aufruf);
};
</script>
</head>
<body onload="getMap()"></body>
</html>