@steady-entertainment
change the path to
/images/yourfile.png
and store your files in public/images directory.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello community,
I want to change the default marker symbol to another marker symbol.
This is home.blade.php file
My problem is that I want to reference another png as my marker.
But I really don't where I have to put the donut.png inside my working tree so i can reference it correctly in the script tag.
<div
id="mapid"
class="h-screen"
></div >
<script >
let mymap = L.map('mapid').setView([0, 0], 3);
const myIcon = L.icon({
iconUrl: 'svg/donut.png', <------------ WHAT IS THE CORRECT PATH?
iconSize: [50, 33],
iconAnchor: [22, 94],
});
const marker = L.marker([0, 0, {icon: myIcon}]).addTo(mymap);
marker.setLatLng([50, 20]);
At the moment I have everything like this, but it doesn't work:
https://i.imgur.com/ez16NaC.png
the icon is saved under public/svg
I really don't know what did the trick but I changed the tile provider and I changed some variable types from const to var and the other way around
I really don't know what was wrong before but now its working seamlessly :D
https://i.imgur.com/deLQOwC.png
{{--<img src={{ URL::asset('/images/iss.png') }} alt="">--}}
<div
id="mapid"
class="h-screen"
></div >
@push('head-scripts')
<script
src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""
>
</script >
@endpush
<script >
lat = 22;
lon = 22;
const mymap = L.map('mapid').setView([lat, lon], 3);
var redcircle = L.circle([51.508, -0.11], {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 500
}).addTo(mymap);
var myIcon = L.icon({
iconUrl: 'http://livewiretest.test/images/donut.png',
iconSize: [38, 95],
iconAnchor: [22, 94],
});
L.marker([50.505, 30.57], {icon: myIcon}).addTo(mymap);
const tileUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const tiles = L.tileLayer(tileUrl);
tiles.addTo(mymap);
// const marker = L.marker([lat, lon]).addTo(mymap);
</script >
Please or to participate in this conversation.