175e7614aSGreg Roach<?php use Fisharebest\Webtrees\I18N; 275e7614aSGreg Roachuse Fisharebest\Webtrees\View; ?> 375e7614aSGreg Roach<?php ?> 4dd6b2bfcSGreg Roach 5dd6b2bfcSGreg Roach<?= view('components/breadcrumbs', ['links' => $breadcrumbs]) ?> 6dd6b2bfcSGreg Roach 7dd6b2bfcSGreg Roach<h1><?= $title ?></h1> 8dd6b2bfcSGreg Roach 9dd6b2bfcSGreg Roach<div class="form-group row"> 10dd6b2bfcSGreg Roach <div class="col-sm-10 offset-sm-1"> 11*0b4092edSGreg Roach <div id="osm-map" class="wt-ajax-load col-sm-12 osm-admin-map" dir="ltr"></div> 12dd6b2bfcSGreg Roach </div> 13dd6b2bfcSGreg Roach</div> 14dd6b2bfcSGreg Roach 15dd6b2bfcSGreg Roach<form method="post"> 16dd6b2bfcSGreg Roach <?= csrf_field() ?> 178af6bbf8SGreg Roach <input type="hidden" name="place_id" value="<?= e($place_id) ?>"> 18dd6b2bfcSGreg Roach <input type="hidden" name="level" value="<?= count($hierarchy) ?>"> 198af6bbf8SGreg Roach <input type="hidden" name="place_long" value="<?= e($lng) ?>"> 208af6bbf8SGreg Roach <input type="hidden" name="place_lati" value="<?= e($lat) ?>"> 21dd6b2bfcSGreg Roach 22dd6b2bfcSGreg Roach <div class="form-group row"> 23dd6b2bfcSGreg Roach <label class="col-form-label col-sm-1" for="new_place_name"> 24dd6b2bfcSGreg Roach <?= I18N::translate('Place') ?> 25dd6b2bfcSGreg Roach </label> 26dd6b2bfcSGreg Roach <div class="col-sm-5"> 278af6bbf8SGreg Roach <input type="text" id="new_place_name" name="new_place_name" value="<?= e($location->locationName()) ?>" 28dd6b2bfcSGreg Roach class="form-control" required> 29dd6b2bfcSGreg Roach </div> 30dd6b2bfcSGreg Roach <label class="col-form-label col-sm-1" for="icon"> 31dd6b2bfcSGreg Roach <?= I18N::translate('Flag') ?> 32dd6b2bfcSGreg Roach </label> 33dd6b2bfcSGreg Roach <div class="col-sm-4"> 34dd6b2bfcSGreg Roach <div class="input-group" dir="ltr"> 35b6c326d8SGreg Roach <input type="text" name="icon" id="icon" class="form-control" value="<?= e($location->icon()) ?>"> 36dd6b2bfcSGreg Roach </div> 37dd6b2bfcSGreg Roach </div> 38dd6b2bfcSGreg Roach </div> 39dd6b2bfcSGreg Roach 40dd6b2bfcSGreg Roach <div class="form-group row"> 4156a34df1SGreg Roach <label class="col-form-label col-sm-1" for="new_place_lati"> 42dd6b2bfcSGreg Roach <?= I18N::translate('Latitude') ?> 43dd6b2bfcSGreg Roach </label> 44dd6b2bfcSGreg Roach <div class="col-sm-3"> 45dd6b2bfcSGreg Roach <div class="input-group"> 460e7a2d23SGreg Roach <input type="text" dir="ltr" id="new_place_lati" class="editable form-control" name="new_place_lati" required 478af6bbf8SGreg Roach placeholder="<?= I18N::translate('degrees') ?>" value="<?= e($lat) ?>" 48dd6b2bfcSGreg Roach > 49dd6b2bfcSGreg Roach </div> 50dd6b2bfcSGreg Roach </div> 51dd6b2bfcSGreg Roach 5256a34df1SGreg Roach <label class="col-form-label col-sm-1" for="new_place_long"> 53dd6b2bfcSGreg Roach <?= I18N::translate('Longitude') ?> 54dd6b2bfcSGreg Roach </label> 55dd6b2bfcSGreg Roach <div class="col-sm-3"> 56dd6b2bfcSGreg Roach <div class="input-group"> 570e7a2d23SGreg Roach <input type="text" dir="ltr" id="new_place_long" class="editable form-control" name="new_place_long" required 588af6bbf8SGreg Roach placeholder="<?= I18N::translate('degrees') ?>" value="<?= e($lng) ?>" 59dd6b2bfcSGreg Roach > 60dd6b2bfcSGreg Roach </div> 61dd6b2bfcSGreg Roach </div> 62dd6b2bfcSGreg Roach <label class="col-form-label col-sm-1" for="new_zoom_factor"> 63dd6b2bfcSGreg Roach <?= I18N::translate('Zoom') ?> 64dd6b2bfcSGreg Roach </label> 65dd6b2bfcSGreg Roach <div class="col-sm-2"> 668af6bbf8SGreg Roach <input type="text" id="new_zoom_factor" name="new_zoom_factor" value="<?= e($location->zoom()) ?>" 67dd6b2bfcSGreg Roach class="form-control" required readonly> 68dd6b2bfcSGreg Roach </div> 69dd6b2bfcSGreg Roach </div> 70dd6b2bfcSGreg Roach 71dd6b2bfcSGreg Roach <div class="form-group row"> 72dd6b2bfcSGreg Roach <div class="col-sm-10 offset-sm-1"> 73dd6b2bfcSGreg Roach <button class="btn btn-primary" type="submit"> 74dd6b2bfcSGreg Roach <?= /* I18N: A button label. */ 75dd6b2bfcSGreg Roach I18N::translate('save') 76dd6b2bfcSGreg Roach ?> 77dd6b2bfcSGreg Roach </button> 78dd6b2bfcSGreg Roach <a class="btn btn-secondary" href="<?= e(route('map-data', ['parent_id' => $parent_id])) ?>"> 79dd6b2bfcSGreg Roach <?= I18N::translate('cancel') ?> 80dd6b2bfcSGreg Roach </a> 81dd6b2bfcSGreg Roach </div> 82dd6b2bfcSGreg Roach </div> 83dd6b2bfcSGreg Roach</form> 84dd6b2bfcSGreg Roach 85dd6b2bfcSGreg Roach<?php View::push('styles') ?> 86dd6b2bfcSGreg Roach<style> 87dd6b2bfcSGreg Roach .osm-wrapper, .osm-user-map { 88dd6b2bfcSGreg Roach height: 45vh 89dd6b2bfcSGreg Roach } 90dd6b2bfcSGreg Roach 91dd6b2bfcSGreg Roach .osm-admin-map { 92dd6b2bfcSGreg Roach height: 55vh; 93dd6b2bfcSGreg Roach border: 1px solid darkGrey 94dd6b2bfcSGreg Roach } 95dd6b2bfcSGreg Roach 96dd6b2bfcSGreg Roach .osm-sidebar { 97dd6b2bfcSGreg Roach height: 100%; 98dd6b2bfcSGreg Roach overflow-y: auto; 99dd6b2bfcSGreg Roach padding: 0; 100dd6b2bfcSGreg Roach margin: 0; 101dd6b2bfcSGreg Roach border: 0; 102dd6b2bfcSGreg Roach display: none; 103dd6b2bfcSGreg Roach font-size: small; 104dd6b2bfcSGreg Roach } 105dd6b2bfcSGreg Roach 106dd6b2bfcSGreg Roach .osm-sidebar .gchart { 107dd6b2bfcSGreg Roach margin: 1px; 108dd6b2bfcSGreg Roach padding: 2px 109dd6b2bfcSGreg Roach } 110dd6b2bfcSGreg Roach 111dd6b2bfcSGreg Roach .osm-sidebar .gchart img { 112dd6b2bfcSGreg Roach height: 15px; 113dd6b2bfcSGreg Roach width: 25px 114dd6b2bfcSGreg Roach } 115dd6b2bfcSGreg Roach 116dd6b2bfcSGreg Roach .osm-sidebar .border-danger:hover { 117dd6b2bfcSGreg Roach cursor: not-allowed 118dd6b2bfcSGreg Roach } 119dd6b2bfcSGreg Roach</style> 120dd6b2bfcSGreg Roach<?php View::endpush() ?> 121dd6b2bfcSGreg Roach 122dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 123dd6b2bfcSGreg Roach<script type="application/javascript"> 124dd6b2bfcSGreg Roach "use strict"; 125dd6b2bfcSGreg Roach 126dd6b2bfcSGreg Roach window.WT_OSM_ADMIN = (function () { 127dd6b2bfcSGreg Roach let baseData = { 128dd6b2bfcSGreg Roach minZoom: 2, 129dd6b2bfcSGreg Roach providerName: "OpenStreetMap.Mapnik", 130dd6b2bfcSGreg Roach providerOptions: [], 131dd6b2bfcSGreg Roach I18N: { 132dd6b2bfcSGreg Roach zoomInTitle: <?= json_encode(I18N::translate('Zoom in')) ?>, 133dd6b2bfcSGreg Roach zoomOutTitle: <?= json_encode(I18N::translate('Zoom out')) ?>, 134dd6b2bfcSGreg Roach reset: <?= json_encode(I18N::translate('Reset to initial map state')) ?>, 135dd6b2bfcSGreg Roach noData: <?= json_encode(I18N::translate('No mappable items')) ?>, 136dd6b2bfcSGreg Roach error: <?= json_encode(I18N::translate('An unknown error occurred')) ?> 13775e7614aSGreg Roach }, 138dd6b2bfcSGreg Roach }; 139dd6b2bfcSGreg Roach 140dd6b2bfcSGreg Roach let map = null; 141dd6b2bfcSGreg Roach let marker = L.marker([0, 0], { 142dd6b2bfcSGreg Roach draggable: true, 143dd6b2bfcSGreg Roach }); 144dd6b2bfcSGreg Roach /** 145dd6b2bfcSGreg Roach * 146dd6b2bfcSGreg Roach * @private 147dd6b2bfcSGreg Roach */ 148dd6b2bfcSGreg Roach let _drawMap = function () { 149dd6b2bfcSGreg Roach map = L.map("osm-map", { 150dd6b2bfcSGreg Roach center: [0, 0], 151dd6b2bfcSGreg Roach minZoom: baseData.minZoom, // maxZoom set by leaflet-providers.js 152dd6b2bfcSGreg Roach zoomControl: false, // remove default 153dd6b2bfcSGreg Roach }, 154dd6b2bfcSGreg Roach ); 155dd6b2bfcSGreg Roach L.tileLayer.provider(baseData.providerName, baseData.providerOptions).addTo(map); 156dd6b2bfcSGreg Roach L.control.zoom({ // Add zoom with localised text 157dd6b2bfcSGreg Roach zoomInTitle: baseData.I18N.zoomInTitle, 158dd6b2bfcSGreg Roach zoomOutTitle: baseData.I18N.zoomOutTitle, 159dd6b2bfcSGreg Roach }).addTo(map); 160dd6b2bfcSGreg Roach 16175e7614aSGreg Roach // postcss_image_inliner breaks the autodetection of image paths. 16275e7614aSGreg Roach L.Icon.Default.imagePath = <?= json_encode(asset('css/images/')) ?>; 16375e7614aSGreg Roach 164dd6b2bfcSGreg Roach marker 165dd6b2bfcSGreg Roach .on("dragend", function (e) { 166dd6b2bfcSGreg Roach let coords = marker.getLatLng(); 167dd6b2bfcSGreg Roach map.panTo(coords); 168dd6b2bfcSGreg Roach _update_Controls({ 169dd6b2bfcSGreg Roach place: "", 170dd6b2bfcSGreg Roach coords: coords, 171dd6b2bfcSGreg Roach zoom: map.getZoom(), 172dd6b2bfcSGreg Roach }); 173dd6b2bfcSGreg Roach }) 174dd6b2bfcSGreg Roach .addTo(map); 175dd6b2bfcSGreg Roach let searchControl = new window.GeoSearch.GeoSearchControl({ 176dd6b2bfcSGreg Roach provider: new window.GeoSearch.OpenStreetMapProvider(), 177dd6b2bfcSGreg Roach retainZoomLevel: true, 178dd6b2bfcSGreg Roach autoClose: true, 179dd6b2bfcSGreg Roach showMarker: false, 180dd6b2bfcSGreg Roach }); 181dd6b2bfcSGreg Roach 182dd6b2bfcSGreg Roach map 183dd6b2bfcSGreg Roach .addControl(searchControl) 184dd6b2bfcSGreg Roach .on("geosearch/showlocation", function (result) { 185dd6b2bfcSGreg Roach let lat = result.location.y; 186dd6b2bfcSGreg Roach let lng = result.location.x; 187dd6b2bfcSGreg Roach let place = result.location.label.split(",", 1); 188dd6b2bfcSGreg Roach 189dd6b2bfcSGreg Roach marker.setLatLng([lat, lng]); 190dd6b2bfcSGreg Roach map.panTo([lat, lng]); 191dd6b2bfcSGreg Roach 192dd6b2bfcSGreg Roach _update_Controls({ 193dd6b2bfcSGreg Roach place: place.shift(), 194dd6b2bfcSGreg Roach coords: { 195dd6b2bfcSGreg Roach "lat": lat, 196dd6b2bfcSGreg Roach "lng": lng, 197dd6b2bfcSGreg Roach }, 198dd6b2bfcSGreg Roach zoom: map.getZoom(), 199dd6b2bfcSGreg Roach }); 200dd6b2bfcSGreg Roach }) 201dd6b2bfcSGreg Roach .on("zoomend", function (e) { 202dd6b2bfcSGreg Roach $("#new_zoom_factor").val(map.getZoom()); 203dd6b2bfcSGreg Roach map.panTo(marker.getLatLng()); 204dd6b2bfcSGreg Roach }); 205dd6b2bfcSGreg Roach }; 206dd6b2bfcSGreg Roach 207dd6b2bfcSGreg Roach let data = <?= json_encode($data) ?>; 208dd6b2bfcSGreg Roach 209dd6b2bfcSGreg Roach /** 210dd6b2bfcSGreg Roach * 211dd6b2bfcSGreg Roach * @param newData 212dd6b2bfcSGreg Roach * @private 213dd6b2bfcSGreg Roach */ 214dd6b2bfcSGreg Roach let _update_Controls = function (newData) { 215dd6b2bfcSGreg Roach let placeEl = $("#new_place_name"); 216dd6b2bfcSGreg Roach if (!placeEl.val().length && newData.place.length) { 217dd6b2bfcSGreg Roach placeEl.val(newData.place); 218dd6b2bfcSGreg Roach } 219dd6b2bfcSGreg Roach $("#new_place_lati").val(Number(newData.coords.lat).toFixed(5)); // 5 decimal places (about 1 metre accuracy) 220dd6b2bfcSGreg Roach $("#new_place_long").val(Number(newData.coords.lng).toFixed(5)); 221dd6b2bfcSGreg Roach $("#new_zoom_factor").val(Number(newData.zoom)); 222dd6b2bfcSGreg Roach }; 223dd6b2bfcSGreg Roach 224dd6b2bfcSGreg Roach $(function () { 225dd6b2bfcSGreg Roach $(".editable").on("change", function (e) { 226dd6b2bfcSGreg Roach let lat = $("#new_place_lati").val(); 227dd6b2bfcSGreg Roach let lng = $("#new_place_long").val(); 228dd6b2bfcSGreg Roach marker.setLatLng([lat, lng]); 229dd6b2bfcSGreg Roach map.panTo([lat, lng]); 230dd6b2bfcSGreg Roach }); 231dd6b2bfcSGreg Roach }); 232dd6b2bfcSGreg Roach 233dd6b2bfcSGreg Roach /** 234dd6b2bfcSGreg Roach * 235dd6b2bfcSGreg Roach * @param id 236dd6b2bfcSGreg Roach */ 237dd6b2bfcSGreg Roach let initialize = function (id) { 238dd6b2bfcSGreg Roach _drawMap(); 239dd6b2bfcSGreg Roach 240dd6b2bfcSGreg Roach marker.setLatLng(data.coordinates); 241dd6b2bfcSGreg Roach 242dd6b2bfcSGreg Roach if (data.coordinates[0] === 0 && data.coordinates[1] === 0) { 243dd6b2bfcSGreg Roach map.fitWorld(); 244dd6b2bfcSGreg Roach } else { 245dd6b2bfcSGreg Roach map.setView(data.coordinates, data.zoom); 246dd6b2bfcSGreg Roach } 247dd6b2bfcSGreg Roach }; 248dd6b2bfcSGreg Roach 249dd6b2bfcSGreg Roach return { 250dd6b2bfcSGreg Roach /** 251dd6b2bfcSGreg Roach * 252dd6b2bfcSGreg Roach * @param id 253dd6b2bfcSGreg Roach */ 254dd6b2bfcSGreg Roach drawMap: function (id) { 255dd6b2bfcSGreg Roach initialize(id); 256dd6b2bfcSGreg Roach }, 257dd6b2bfcSGreg Roach }; 258dd6b2bfcSGreg Roach })(); 259dd6b2bfcSGreg Roach 260dd6b2bfcSGreg Roach WT_OSM_ADMIN.drawMap(<?= json_encode($ref) ?>); 261dd6b2bfcSGreg Roach</script> 262dd6b2bfcSGreg Roach<?php View::endpush() ?> 263