Viewing file: 170e7594fd4726bdc3e2741a85458637.php (7.49 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<script src="<?php echo e(asset('frontend')); ?>/js/axios.min.js"></script> <?php if (isset($component)) { $__componentOriginale8c9e08de211331e5ea62140e4549a3b = $component; } ?> <?php if (isset($attributes)) { $__attributesOriginale8c9e08de211331e5ea62140e4549a3b = $attributes; } ?> <?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.map.leaflet.map_scripts','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?> <?php $component->withName('map.leaflet.map_scripts'); ?> <?php if ($component->shouldRender()): ?> <?php $__env->startComponent($component->resolveView(), $component->data()); ?> <?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?> <?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?> <?php endif; ?> <?php $component->withAttributes([]); ?> <?php echo $__env->renderComponent(); ?> <?php endif; ?> <?php if (isset($__attributesOriginale8c9e08de211331e5ea62140e4549a3b)): ?> <?php $attributes = $__attributesOriginale8c9e08de211331e5ea62140e4549a3b; ?> <?php unset($__attributesOriginale8c9e08de211331e5ea62140e4549a3b); ?> <?php endif; ?> <?php if (isset($__componentOriginale8c9e08de211331e5ea62140e4549a3b)): ?> <?php $component = $__componentOriginale8c9e08de211331e5ea62140e4549a3b; ?> <?php unset($__componentOriginale8c9e08de211331e5ea62140e4549a3b); ?> <?php endif; ?> <?php if (isset($component)) { $__componentOriginal513663b5c5fac5e7b3365170a423e764 = $component; } ?> <?php if (isset($attributes)) { $__attributesOriginal513663b5c5fac5e7b3365170a423e764 = $attributes; } ?> <?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.map.leaflet.autocomplete_scripts','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?> <?php $component->withName('map.leaflet.autocomplete_scripts'); ?> <?php if ($component->shouldRender()): ?> <?php $__env->startComponent($component->resolveView(), $component->data()); ?> <?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?> <?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?> <?php endif; ?> <?php $component->withAttributes([]); ?> <?php echo $__env->renderComponent(); ?> <?php endif; ?> <?php if (isset($__attributesOriginal513663b5c5fac5e7b3365170a423e764)): ?> <?php $attributes = $__attributesOriginal513663b5c5fac5e7b3365170a423e764; ?> <?php unset($__attributesOriginal513663b5c5fac5e7b3365170a423e764); ?> <?php endif; ?> <?php if (isset($__componentOriginal513663b5c5fac5e7b3365170a423e764)): ?> <?php $component = $__componentOriginal513663b5c5fac5e7b3365170a423e764; ?> <?php unset($__componentOriginal513663b5c5fac5e7b3365170a423e764); ?> <?php endif; ?> <script> var oldlat = <?php echo e(Session::has('location') ? Session::get('location')['lat'] : setting('default_lat')); ?>; var oldlng = <?php echo e(Session::has('location') ? Session::get('location')['lng'] : setting('default_long')); ?>;
// Map preview var element = document.getElementById('leaflet-map');
// Height has to be set. You can do this in CSS too. if (element) element.style = 'height:300px;';
// Create Leaflet map on map element. var leaflet_map = L.map(element);
// Add OSM tile layer to the Leaflet map. L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(leaflet_map);
// Target's GPS coordinates. var target = L.latLng(oldlat, oldlng);
// Set map's center to target with zoom 14. const zoom = 7; leaflet_map.setView(target, zoom);
// Place a marker on the same location. var markers = new L.FeatureGroup(); var marker = L.marker(target, { draggable: true });
marker.addTo(markers); markers.addTo(leaflet_map);
// marker drugEnd marker.on("dragend", function(e) { var marker = e.target; var position = marker.getLatLng(); leaflet_map.panTo(new L.LatLng(position.lat, position.lng)); // call api to get address from lat & lng $.get(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${position.lat}&lon=${ position.lng}`, function( data) { var country = data.address.country; var region = data.address.state; var district = data.address.state_district; var place = data.address.city;
// save location data in session var form = new FormData(); form.append('lat', position.lat); form.append('lng', position.lng);
form.append('country', country); form.append('region', region); form.append('district', district); form.append('place', place);
axios.post( '/set/session', form ) .then((res) => { // console.log(res.data); // toastr.success("Location Saved", 'Success!'); }) .catch((e) => { toastr.error("Something Wrong", 'Error!'); }); }); // call api to get address from lat & lng END
}); // marker drugEnd END
// map click set marker leaflet_map.on('click', function(e) {
let lat = e.latlng.lat; let lng = e.latlng.lng; leaflet_map.panTo(new L.LatLng(lat, lng));
markers.clearLayers(); //c clear old merkers
// re init marker var marker = L.marker([lat, lng], { draggable: true }); setTimeout(() => { marker.addTo(markers); markers.addTo(leaflet_map); }, 100); // re init marker END
// call api to get address from lat & lng $.get(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${lat}&lon=${lng}`, function( data) { var country = data.address.country; var region = data.address.state; var district = data.address.state_district; var place = data.address.city; // save location data in session var form = new FormData(); form.append('lat', lat); form.append('lng', lng);
form.append('country', country); form.append('region', region); form.append('district', district); form.append('place', place);
axios.post( '/set/session', form ) .then((res) => { // console.log(res.data); // toastr.success("Location Saved", 'Success!'); }) .catch((e) => { toastr.error("Something Wrong", 'Error!'); }); }); // call api to get address from lat & lng END
}); // map click set marker END </script> <?php /**PATH E:\add listing 8-9-25\addListing\resources\views/components/map/leaflet/leafletmap.blade.php ENDPATH**/ ?>
|