410fc86c60
The map script loaded https://static.neshan.org/sdk/leaflet/1.4.0/neshan-sdk/v1.0.8/index.js, which Neshan has removed (returns 404) — so window.L never defined, the init bailed, and NO map rendered anywhere (detail pages + the facility-register picker). Switch to Neshan''s current SDK (.../1.4.0/leaflet.js + leaflet.css, both 200). The init API is unchanged (new L.Map with the maptype option), so no other code changes needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
1.3 KiB
Plaintext
29 lines
1.3 KiB
Plaintext
@model string
|
|
@*
|
|
Read-only Neshan map. Render once per page AFTER an element <div id="facmap"
|
|
data-lat="…" data-lng="…"> exists. Pass the Neshan web key as the model.
|
|
The SDK is a synchronous script, so the init below runs once L is defined.
|
|
*@
|
|
<link rel="stylesheet" href="https://static.neshan.org/sdk/leaflet/1.4.0/leaflet.css" />
|
|
<script src="https://static.neshan.org/sdk/leaflet/1.4.0/leaflet.js"></script>
|
|
<script>
|
|
(function () {
|
|
var el = document.getElementById('facmap');
|
|
if (!el || !window.L) return;
|
|
var lat = parseFloat(el.dataset.lat), lng = parseFloat(el.dataset.lng);
|
|
if (isNaN(lat) || isNaN(lng)) return;
|
|
// Approximate (aggregated) listings show a shaded AREA circle, not a precise pin.
|
|
var approx = el.dataset.approx === 'true';
|
|
var map = new L.Map('facmap', {
|
|
key: '@Model', maptype: 'neshan', poi: !approx, traffic: false,
|
|
center: [lat, lng], zoom: approx ? 14 : 15
|
|
});
|
|
if (approx) {
|
|
var radius = parseInt(el.dataset.radius || '700', 10);
|
|
L.circle([lat, lng], { radius: radius, color: '#e07b39', weight: 1, fillColor: '#e07b39', fillOpacity: 0.18 }).addTo(map);
|
|
} else {
|
|
L.marker([lat, lng]).addTo(map);
|
|
}
|
|
})();
|
|
</script>
|