0

I have an API that generates information in XML form, I have tried using a foreach loop,

<script>
<?php 
$xml = simplexml_load_file("https://www.simbrief.com/api/xml.fetcher.php?username=bateseyplayz");

foreach ($xml->navlog->fix as $fix){
    echo 'L.marker([$fix->pos_lat, $fix->pos_long]).addTo(mymap)';
}
?>
</script>

This breaks my leaflet map probably because of how I am trying to echo the code to make a marker, I have other markers on my map from using this API but they have different names so I don't have to loop to get the coordinates for these points

If anyone has any better solutions would be greatly appreciated

The API should work if you just copy into a browser

Many Thanks

Batesey
  • 3
  • 1
  • Changing the quotes to double quotes should give you the co-ordinates, but you may also need something like `.PHP_EOL` on the end to make it separate lines of code. – Nigel Ren Jun 27 '20 at 10:55
  • @NigelRen Thanks for the response but this has not really been much help because I can get the co ordinates fine the problem is getting it to work on the leaflet map – Batesey Jun 28 '20 at 20:11
  • So have you checked the javascript that is generated and see what it's doing? – Nigel Ren Jun 28 '20 at 20:14

0 Answers0