처음으로 리플릿/자바 스크립트를 사용하고 있으며 이동할 때마다 변경되는 GeoJSON 레이어가있는지도를 표시하고 싶습니다. 영역의 포인트 만 표시합니다. 내가 처음으로 함수에서 층을 제거하기 위해 시도했지만 GeoJSONlayer 내가 onMove()에서 층을 제거하기 위해 노력했다 를 정의하지 않고, 아무것도 I를 나타납니다경계 상자 안의 데이터가있는 전단지 GeoJSON 레이어 업데이트
// Function to refresh points to display
function actualiseGeoJSON() {
// Default icon for my points
var defaultIcon = L.icon({
iconUrl: '../images/icones/cabane.png',
iconSize: [16, 16],
iconAnchor: [8, 8],
popupAnchor: [0, -8]
});
// We create each point with its style (from GeoJSON file)
function onEachFeature(feature, layer) {
var popupContent = '<a href="' + feature.properties.url + '">' + feature.properties.nom + "</a>";
layer.bindPopup(popupContent);
var cabaneIcon = L.icon({
iconUrl: '../images/icones/' + feature.properties.type + '.png',
iconSize: [16, 16],
iconAnchor: [8, 8],
popupAnchor: [0, -8]
});
layer.setIcon(cabaneIcon);
}
// We download the GeoJSON file (by using ajax plugin)
var GeoJSONlayer = L.geoJson.ajax('../exportations/exportations.php?format=geojson&bbox=' + map.getBounds().toBBoxString() + '',{
onEachFeature: onEachFeature,
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {icon: defaultIcon});
}
}).addTo(map);
}
// We create the map
var map = L.map('map');
L.tileLayer('http://maps.refuges.info/hiking/{z}/{x}/{y}.png', {
attribution: '© Contributeurs d\'<a href="http://openstreetmap.org">OpenStreetMap</a>',
maxZoom: 18
}).addTo(map);
// An empty base layer
var GeoJSONlayer = L.geoJson().addTo(map);
// Used to only show your area
function onLocationFound(e) {
var radius = e.accuracy/2;
L.marker(e.latlng).addTo(map);
actualiseGeoJSON();
}
function onLocationError(e) {
alert(e.message);
actualiseGeoJSON();
}
function onMove() {
// map.removeLayer(GeoJSONlayer);
actualiseGeoJSON();
}
map.locate({setView: true, maxZoom: 14});
// Datas are modified if
map.on('locationerror', onLocationError);
map.on('locationfound', onLocationFound);
map.on('moveend', onMove);
:
이 내 코드의 소스 moveend 이벤트에 층을 제거하려하지만 내 나쁜 영어, 프랑스어 남자 i 번째 fren 용
누군가가 나를 도울 수 있다면
...죄송합니다 구문 오류가 있습니다 ch 함수 이름
faut apprendre l' anglais mec! :) –
및 위치 정확도의 원을 그리는 것처럼 보이지 않으므로 반지름 변수가 필요하지 않습니다. – Rmatt