• Hello,
    so I’m updating my code so- I am creating maps on the fly based on archival reports from the Royal Navy of where all their ships were on a particular date in the 17th C. (To see what I’m doing- go to choose a report, then any one from the list, and you’ll see- A map should come up)

    I have different kinds of reports, and I’d like to change the colour of the marker depending on the type of report (Eg blue = deployment report, red = status report, yellow = fleet list). I’ve seen where you said you can use SVG Markers, but I can’t’ seem to get this to work. While I’m using wordpress, I’m mostly working around it- creating HTML instead of actually using my theme.

    `function print_deployment_map($array_of_locations)
    {
    //this is using the leaflet app
    echo do_shortcode(“[leaflet-map fitbounds zoomcontrol]”);
    foreach( $array_of_locations as $marker)
    {
    //var_dump ($marker);
    //echo ‘<br>’;
    echo do_shortcode(“[leaflet-marker svg=”true” background=\”$marker[4]\” lat=\”$marker[1]\” lng=\”$marker[2]\”]$marker[0][/leaflet-marker]”);
    }
    }

    Im just wondering where I’m going wrong.

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author bozdoz

    (@bozdoz)

    I don’t see anything wrong. What happens? Nothing? Is there a javascript error in the developer console? What is the output of var_dump($marker)?

    Thread Starter samuel1mclean

    (@samuel1mclean)

    oh, like the map and all the markers show up- but they’re all blue, just standard. I’ve tried changing it to green, red, various other things, but the colour doesn’t change.

    Hello,

    I’m new in WordPress an Leaflet but I have the same problem actually. I tried different things to get different marker colors but nothing worked.

    Plugin Contributor hupe13

    (@hupe13)

    @samuel1mclean: Is $marker[4] a color like “yellow”. Or should it be $marker[3]?
    Or the " and \" aren’t right.

    echo do_shortcode('[leaflet-marker svg="true" background="'.$marker[3].'" lat="'.$marker[1].'" lng="'.$marker[2].'"]'.$marker[0].'[/leaflet-marker]');

    Thread Starter samuel1mclean

    (@samuel1mclean)

    @hupe13 yes, value of marker[4] is a colour- “red”, “blue”, “green” or “yellow”…

    but *swears at self* I think you’re right, that’s probably an issue. Let me check.

    Thread Starter samuel1mclean

    (@samuel1mclean)

    @hupe13 you were correct in that I was calling on the wrong part of the array, but fixing that hasn’t changed the colour of the markers, unfortunately.

    Plugin Contributor hupe13

    (@hupe13)

    Did you try my above code with the right parts of the array? This works, I tested it.

    Thread Starter samuel1mclean

    (@samuel1mclean)

    @hupe13 I did now, and you’re right, it works. The icons aren’t nearly as attractive, it’s fine.

    This is great, it means I can do all kinds of neat things with the maps now.

    Plugin Author bozdoz

    (@bozdoz)

    @samuel1mclean Agreed, the svg markers are quite flat.

    @hupe13 Thanks for the help!

    @margon0815 Were you able to resolve your issue?

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Choosing marker colours’ is closed to new replies.