According to your description, some browsers forbid using absolute paths access to local files for security reasons.
If your image is in your project folder, I recommend that you use virtual paths.
Indra JRN
var image = '~assets/images/jrn/equipment/bar_coktail.png';
Since I don't know the hierarchical relationship between your image and the folder where you run the program, I have made a simple example for you to refer to:
None
0 Points
8 Posts
[SOLVED] Custom Marker Icon Google Maps Not Show
Jul 12, 2019 02:59 AM|Indra JRN|LINK
Hi Guys,
I have new problem with icon marker on google maps.
I was write like this
var image = 'E:/Project/mytrackingsystem/MvcApplication1/assets/images/jrn/equipment/bar_coktail.png';
if (markers[data[i].equ_accpac] == undefined) {
marker = new google.maps.Marker({
position: myCenter,
map: map,
draggable: true,
icon: image,
title: data[i].equ_accpac,
label: 'Info'
});
markers[data[i].equ_accpac] = marker;
}
else {
markers[data[i].equ_accpac].setPosition(myCenter);
}
or i change image variable, like as :
var image = '~assets/images/jrn/equipment/bar_coktail.png';
But that Icon still no show
and when i change that image variable with url like :
var image = 'https://www.mapsmarker.com/wp-content/uploads/leaflet-maps-marker-icons/bar_coktail.png'
that icon appear.
pls help me to do this,
or just image "online" can be ?
regards
Contributor
3710 Points
1043 Posts
Re: [SOLVED] Custom Marker Icon Google Maps Not Show
Jul 12, 2019 08:09 AM|Yongqing Yu|LINK
Hi Indra,
According to your description, some browsers forbid using absolute paths access to local files for security reasons.
If your image is in your project folder, I recommend that you use virtual paths.
Since I don't know the hierarchical relationship between your image and the folder where you run the program, I have made a simple example for you to refer to:
My picture location:
C:\Users\yongqy\source\repos\CaseProject\MVC_Cases\Images1\ppc.png
My Index.cshtml:
C:\Users\yongqy\source\repos\CaseProject\MVC_Cases\Views\UpdateTable\Index.cshtml
So the virtual path of the picture is written like this:
It can show this image successfully.
You can also refer to this link : Not allowed to load local resources
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.