Skip to content

Commit 36036b3

Browse files
authored
Merge pull request #4 from NHSDigital/osmaps-key
Remove script include for now
2 parents ad51904 + 753b22d commit 36036b3

3 files changed

Lines changed: 101 additions & 51 deletions

File tree

app/assets/javascript/map-scripts.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/views/pre-alpha-flats/bso/bso-internal-details.html

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,61 @@ <h2 class="nhsuk-heading-m">BSO area</h2>
161161
<script src="https://unpkg.com/maplibre-gl@5.3.0/dist/maplibre-gl.js"></script>
162162
<script src="https://unpkg.com/@maplibre/maplibre-gl-leaflet@0.1.0/leaflet-maplibre-gl.js"></script>
163163

164-
<script src="/assets/javascript/map-scripts.js"></script>
164+
<script>
165+
function circleIcon({ fill = '#fff', stroke = '#000', strokeWidth = 2,
166+
text = '', textColor = '#000', radius = 14, fillOpacity = 1 } = {}) {
167+
const width = radius * 2;
168+
const pointHeight = radius * 1.2;
169+
const height = width + pointHeight;
170+
const cx = radius;
171+
const cy = radius;
172+
173+
return L.divIcon({
174+
html: `<svg viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
175+
<!-- Stroke-only pin line -->
176+
<line
177+
x1="${cx}" y1="${cy + radius - strokeWidth}"
178+
x2="${cx}" y2="${height - strokeWidth}"
179+
stroke="${stroke}" stroke-width="${strokeWidth}"/>
180+
<!-- Filled circle on top -->
181+
<circle
182+
cx="${cx}" cy="${cy}" r="${radius - strokeWidth}"
183+
fill="${fill}" fill-opacity="${fillOpacity}" stroke="${stroke}" stroke-width="${strokeWidth}"/>
184+
<!-- Text -->
185+
<text x="${cx}" y="${cy}" text-anchor="middle" dominant-baseline="central"
186+
fill="${textColor}" font-size="${radius * 0.9}" font-family="sans-serif" font-weight="bold">
187+
${text}
188+
</text>
189+
</svg>`,
190+
className: '',
191+
iconSize: [width, height],
192+
iconAnchor: [cx, height],
193+
popupAnchor: [0, -height]
194+
});
195+
}
196+
197+
const landmarkIcons = {
198+
orgLocation: circleIcon({ fill: '#fff9c4', text: 'O' }),
199+
static: circleIcon({ fill: '#fff9c4', text: 'S' }),
200+
mobile: circleIcon({ fill: '#ed8b00', text: 'M' }),
201+
default: circleIcon({ fill: '#fff', text: '' }),
202+
};
203+
204+
const mapOptions = {
205+
attributionControl: false,
206+
scrollWheelZoom: false
207+
};
208+
209+
const map = L.map('app-map', {
210+
maxZoom: 15
211+
});
212+
</script>
213+
165214
<script src="geo-bso-west-berks.js"></script>
166215

167216
<script>
168217

169-
const apiKey = 't9ErutMVGdziLrLqJbCM049xw5550C0e';
218+
const apiKey = 'lWF9hAvJ3ALTasfGgV8MqmfAWJ2L9fhU';
170219

171220
landmarks.forEach(({ lat, lng, type, name }) => {
172221
const icon = landmarkIcons[type] || landmarkIcons.default;

app/views/pre-alpha-flats/location/location-location-details.html

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,58 @@ <h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-0">Location notes for participa
169169
<script src="https://unpkg.com/maplibre-gl@5.3.0/dist/maplibre-gl.js"></script>
170170
<script src="https://unpkg.com/@maplibre/maplibre-gl-leaflet@0.1.0/leaflet-maplibre-gl.js"></script>
171171

172-
<script src="/assets/javascript/map-scripts.js"></script>
172+
<script>
173+
function circleIcon({ fill = '#fff', stroke = '#000', strokeWidth = 2,
174+
text = '', textColor = '#000', radius = 14, fillOpacity = 1 } = {}) {
175+
const width = radius * 2;
176+
const pointHeight = radius * 1.2;
177+
const height = width + pointHeight;
178+
const cx = radius;
179+
const cy = radius;
180+
181+
return L.divIcon({
182+
html: `<svg viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
183+
<!-- Stroke-only pin line -->
184+
<line
185+
x1="${cx}" y1="${cy + radius - strokeWidth}"
186+
x2="${cx}" y2="${height - strokeWidth}"
187+
stroke="${stroke}" stroke-width="${strokeWidth}"/>
188+
<!-- Filled circle on top -->
189+
<circle
190+
cx="${cx}" cy="${cy}" r="${radius - strokeWidth}"
191+
fill="${fill}" fill-opacity="${fillOpacity}" stroke="${stroke}" stroke-width="${strokeWidth}"/>
192+
<!-- Text -->
193+
<text x="${cx}" y="${cy}" text-anchor="middle" dominant-baseline="central"
194+
fill="${textColor}" font-size="${radius * 0.9}" font-family="sans-serif" font-weight="bold">
195+
${text}
196+
</text>
197+
</svg>`,
198+
className: '',
199+
iconSize: [width, height],
200+
iconAnchor: [cx, height],
201+
popupAnchor: [0, -height]
202+
});
203+
}
204+
205+
const landmarkIcons = {
206+
orgLocation: circleIcon({ fill: '#fff9c4', text: 'O' }),
207+
static: circleIcon({ fill: '#fff9c4', text: 'S' }),
208+
mobile: circleIcon({ fill: '#ed8b00', text: 'M' }),
209+
default: circleIcon({ fill: '#fff', text: '' }),
210+
};
211+
212+
const mapOptions = {
213+
attributionControl: false,
214+
scrollWheelZoom: false
215+
};
216+
217+
const map = L.map('app-map', {
218+
maxZoom: 15
219+
});
220+
</script>
173221

174222
<script>
175-
const apiKey = 't9ErutMVGdziLrLqJbCM049xw5550C0e';
223+
const apiKey = 'lWF9hAvJ3ALTasfGgV8MqmfAWJ2L9fhU';
176224

177225
const landmarks = [
178226
{ lat: 51.4712253052667, lng: -0.09312137796810355, type: 'location', name: 'Camberwell Building' }

0 commit comments

Comments
 (0)