Odd Javascript Behavior

Hi all

I am using Javascript to create a Leaflet map in an HTMLViewer. This all works with no issues. Where I am running into a problem is trying to add multiple markers to the map. If I execute my JS code via Xojo I am only getting one marker. However if I run the same code in the Chrome console I get all the points I expect. It appears that for whatever reason my loop in JS is not running when executed in Xojo. Here is the JS code I am using:

var locations = [
["LOCATION_0", 37.42228990140251,-122.0822035425683],
["LOCATION_1", 37.4220033612141,-122.084075],
["LOCATION_2", 37.42156927867553,-122.0857667006183],
["LOCATION_3", 37.42243077405461,-122.0856545755255]

var map = L.map('map').setView([37.42228990140251,-122.0822035425683], 15);

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
    maxZoom: 19,
    attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'

for (var i = 0; i < locations.length; i++) {
    marker = new L.marker([locations[i][1], locations[i][2]])

What platform are you on?

I am debugging on Windows in 2022r3.2 and compiling for Linux ARM 32-bit and see the behavior on both.

Is the openstretmap added to an iframe?
Ooh sorry noticed you used a HTMLViewer, maybe has something to do with the permssions to the frame? Probably has someting to do with the origin not accepting your javascript since on debugbuilds you are on localhost. Did you try to test in in an build online version?

Yes, I have tried a built version as well and have seen the same behavior.

Desktop or web?

It is web

Ok, so @DerkJ is correct that there’s probably a problem with the code running in a frame. When you open the page, go to the browser’s developer tools and see if there are any errors there.

So I came back to this after taking some time away from it and have found that adding the loop to a leaflet Layergroup instead of directly to the map allows it to run as expected. No clue why it wouldn’t run just on the map through Xojo but at least I have found a solution.