0
몇 초 후에 페이지를 다시로드하고 새로운 Lat Long 좌표를 포함하는 변수를 URL에 추가하려고합니다.지우는 방법 JavaScript로 URL 추가하기
var latlng = getQueryVariable("latlng");
if(latlng){
console.log(latlng); //working
}
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("?");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('Query Variable ' + variable + ' not found');
}
function onMapClick(e) {//Coordinate pop up
popup.setLatLng(e.latlng)
.setContent("Coordinates clicked are: " + e.latlng.toString())
.openOn(map);
var centerPoint = map.getSize().divideBy(2),
targetPoint = centerPoint.subtract([1500, 0]),
targetLatLng = map.containerPointToLatLng(centerPoint), //retrieve new lat longs
loadLatlng = "?latlng="+targetLatLng.lat+","+targetLatLng.lng;
setTimeout(function(){
//And herein lies the problem - the URL is being concatenated ??
window.location.href = window.location.href + loadLatlng;
window.location.href.reload(1);
}, 5000);
}
사람은 어떻게 취소 알고 다음 URL을 추가 하는가 : 그 아래의 코드는 Leaflet 작동 생각해? 감사합니다. .
이유에 현재의 URL을 분할하여 그것을 더러운 방법을 할 수
로 같은 일이 페이지를 새로 고침 하시겠습니까? 브라우저의 URL 만 변경하려는 목적이 아닙니까? – YaFred
내 응용 프로그램에서 JSON 객체 (geometry 및 stats 등)의 형태로 메모리에 꽤 많은 데이터가 저장되어 있기 때문에 페이지를 다시로드하고 있습니다. 그래서 나는 페이지를 새로 고침하고 사용자를 원래 위치로 되돌릴 것이라고 생각합니다. 약간 조잡하지만 브라우저에서 메모리가 누출 되었다면 어떻게해야할지 모르겠습니다. 페이지를 다시로드하면 메모리가 지워집니다. –