[SOLVED] Custom Marker Icon Google Maps Not Show RRS feed

  • Question

  • User1892050643 posted

    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({
    map: map,
    draggable: true,
    icon: image,
    title: data[i].equ_accpac,
    label: 'Info'
    markers[data[i].equ_accpac] = marker;
    else {

    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 ?


    Friday, July 12, 2019 2:59 AM


  • User665608656 posted

    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.

    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:

    My picture location:


    My Index.cshtml:


    So the virtual path of the picture is written like this:

     var image = "/Images1/ppc.png";

    It can show this image successfully.

    You can also refer to this link : Not allowed to load local resources

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 12, 2019 8:09 AM