OpenMarine
dynamically editing a html page - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1)
+--- Forum: Node Red (https://forum.openmarine.net/forumdisplay.php?fid=15)
+--- Thread: dynamically editing a html page (/showthread.php?tid=4076)



dynamically editing a html page - marty_c - 2022-05-31

I'm new at this but loving what I am seeing. I'm trying to take my current lat/long and make a local html file along these lines Embed VesselFinder map into your website - VesselFinder

Essentially it's just take this:
<script type="text/javascript">
   // Map appearance
   var width="100%";         // width in pixels or percentage
   var height="300";         // height in pixels
   var latitude="36.00";     // center latitude (decimal degrees)
   var longitude="-5.40";    // center longitude (decimal degrees)
   var zoom="8";             // initial zoom (between 3 and 18)
</script>
<script type="text/javascript" src="https://www.vesselfinder.com/aismap.js"></script>



and replace the lat/long with my current position and change the zoom to my preferred. See attached.
My problem is that when I debug and copy the generated text to a new html file on my desktop it works great. When I click on the generated button it takes me to the vesselfinder page but doesn't do any of the customisations. What am I doing wrong?

Cheers


RE: dynamically editing a html page - marty_c - 2022-06-02

(2022-05-31, 09:21 PM)marty_c Wrote: I'm new at this but loving what I am seeing. I'm trying to take my current lat/long and make a local html file along these lines Embed VesselFinder map into your website - VesselFinder

Essentially it's just take this:
<script type="text/javascript">
   // Map appearance
   var width="100%";         // width in pixels or percentage
   var height="300";         // height in pixels
   var latitude="36.00";     // center latitude (decimal degrees)
   var longitude="-5.40";    // center longitude (decimal degrees)
   var zoom="8";             // initial zoom (between 3 and 18)
</script>
<script type="text/javascript" src="https://www.vesselfinder.com/aismap.js"></script>



and replace the lat/long with my current position and change the zoom to my preferred. See attached.
My problem is that when I debug and copy the generated text to a new html file on my desktop it works great. When I click on the generated button it takes me to the vesselfinder page but doesn't do any of the customisations. What am I doing wrong?

Cheers

Ended up being a lot easier than I thought. I just created global variables for latitude and longitude and then used this.

<script type="text/javascript">
    // Map appearance
    var width="100%";         // width in pixels or percentage
    var height="600";         // height in pixels
    var latitude={{global.latitude}};
    var longitude={{global.longitude}};
    var zoom="13";             // initial zoom (between 3 and 18)
</script>
<script type="text/javascript" src="https://www.vesselfinder.com/aismap.js"></script>