diff --git a/public/js/views/map.js b/public/js/views/map.js index 2651a41..b074c3e 100644 --- a/public/js/views/map.js +++ b/public/js/views/map.js @@ -159,14 +159,34 @@ const MapView = { console.warn('updateLocation:', e); } if (this.map) { - this.map.setView([lat, lng], 13); + // важно: invalidateSize() чтобы Leaflet пересчитал размеры (после смены таба лейаут мог обнулиться) + this.map.invalidateSize(); + // убираем старый self-marker и круг + if (this.selfMarker) { this.map.removeLayer(this.selfMarker); this.selfMarker = null; } this.map.eachLayer((layer) => { - if (layer instanceof L.Circle) this.map.removeLayer(layer); + if (layer instanceof L.Circle && layer.options && layer.options._isRadius) { + this.map.removeLayer(layer); + } }); + // маркер "Я" + const meIcon = L.divIcon({ + className: 'self-marker', + html: '
', + iconSize: [18, 18], + iconAnchor: [9, 9], + }); + this.selfMarker = L.marker([lat, lng], { icon: meIcon, zIndexOffset: 1000 }).addTo(this.map); + // круг радиуса L.circle([lat, lng], { radius: this.radius * 1000, - color: '#FF6B35', fillColor: '#FF6B35', fillOpacity: 0.1, weight: 2, + color: '#FF6B35', + fillColor: '#FF6B35', + fillOpacity: 0.1, + weight: 2, + _isRadius: true, }).addTo(this.map); + // центр + zoom на мне + this.map.setView([lat, lng], 14, { animate: true }); this.refreshNearbyFromPos(lat, lng); this.refreshPlacesFromPos(lat, lng); }