Skip to main content

Today I Learned: Pattern for Specifying the CZML Map to Load in an iframe URL

 I learned a way to make my POTA activation blogs a bit easier to create today. 


When to Use the Pattern

When you'd like to use the same Sandcastle to open multiple different czml files without having to edit Sandcastle code every time.

More generally, the pattern can be used to pass any number of URL encoded parameters to your Sandcastle Javascript via your Sandcastle's web address.

What the Pattern Enables

The user can specify a czml file URL like this

https://sandcastle.cesium.com/standalone.html?mapurl=https://raw.githubusercontent.com/hcarter333/rm-rbn-history/refs/heads/main/maps/2024_11_18_Civic_Center_Juan_Bautista.czml#c=dV...

Where the #c is the usual 64 bit encoded contents of your Sandcastle from the share link.

Your Sandcastle will need to include this code through line 15. At that point, you'll have the address of your map in the variable mapurl2 and can do whatever you like with it. In the example above, the czml file pointed to is simply loaded into a Cesium viewer with an OpenStreets map overlay.

Why I Invented the Pattern

In th past, I've navigated to Cesium Sandcastle, loaded in some JavaScript to open a czml file at a URL, then pointed that URL at the CZML defined map for my particular radio outing hosted on Github, and then used the link from the 'Open in New Window' button in an iframe to display the map in my blog post.

I now have a template where I can simply substitute in the URL for the GitHub hosted raw CZML file and I'm off and running.

How I Built This

I asked ChatGPT to create JavaScript for me that would pull the CZML URL out of the browser window's address bar. After a little massaging and debug, I wound up with the source code that enables this pattern.  You can see the code here.

A few notes about the Cesium SandCastle URL

I found out yesterday that the #c marker in the Sandcastle URL is followed by your JavaScript code 64 bit encoded. That's why the link is as long as it is. I also found out that the decoding portion of Cesium,  expects everything after #c to be Base64 encoded information for use by Sandcastle. So, if you'd like to follow this pattern of passing extra arguments to your Sandcastle code in the URL address, be sure to include the extra parameters before the #c anchor as shown below.

In my case, that made the address look like this:

https://sandcastle.cesium.com/standalone.html?mapurl=https://raw.githubusercontent.com/hcarter333/rm-rbn-history/refs/heads/main/maps/2024_11_18_Civic_Center_Juan_Bautista.czml#c=dVPBbtswDP0VwhhQBwhkZAOGLk2zDe0OBTK0WLrt4kMVm3GEyZIh0QnSoP8+yrKbtelOhsjHx8dHOje5WbemIGUNVEh30sk6NbLGERxyA5BlQG4PHqUrNrBWztMYaIMGNtJvAqKwxhN427oC4RJ2ypR2J7QtZCAVsVJoNBVtYA6TUAPw+X9A3648OWWqdDKK0OkJNLQWXqsCGXQxiLAaGVKleRLF5Mlp7u2mRxxBwzMY3MHPH4tll+ws8WnkjEiH1DoDjWDHolkcfspNZKhl0zr9nnmeDc2TGIySXortPD1N9CwhPBAXj7Vm1jzJkwsYgluFO3S96Cv0qq3Fry7G3EX3vrKGpDLo8mQMByB0jp/TAX0f32LtbP3bOl32gXQ0hqfQfysdWF+/7HHboFmSQ6TvsrmpZYVuf+fsVpXc+QCsnRd3tiFq/DTLSPFYlkt8V8LDCeuqs8DfTyBU5FjIPTovZFm+JmUJozB3j/cFGhSVtisUaORK40JVG+LLYaHkWuycC8d7OG436PBIjJA7qWgYJn4+XN/HdGfFjTVfPT9uyvTTx8n5eVz9i+aNU7UitcVOb9qTd8cAfGD8w6RspXWjo4RhvQ/fQgK0lWVQ3JdO4d2hq3h66E9qWHMpSS67E2Q/auXDrzaI57O4fk6LQHm8nqNfR4ao9oQxnloyTmae9hrn8e8D+KLqxjoKK02FyAjrRktCn63a4g+bVXgfvQGYZf+Wzkq1BVVevnGHUGjpPWfWrdZL9cg/63yWMf6ktHfodotOy32AbSbzRQwKIWYZP9+uJGv1SrpXzDzfcJRemrKQnnglUaAobJ1VUms+u+wv


And that address will load the map for the czml file specified immediately after the ? in the URL. The iframe below contains the link above.


Demo

Comments

Popular posts from this blog

The Valentine's Day Magnetic Monopole

There's an assymetry to the form of the two Maxwell's equations shown in picture 1.  While the divergence of the electric field is proportional to the electric charge density at a given point, the divergence of the magnetic field is equal to zero.  This is typically explained in the following way.  While we know that electrons, the fundamental electric charge carriers exist, evidence seems to indicate that magnetic monopoles, the particles that would carry magnetic 'charge', either don't exist, or, the energies required to create them are so high that they are exceedingly rare.  That doesn't stop us from looking for them though! Keeping with the theme of Fairbank[1] and his academic progeny over the semester break, today's post is about the discovery of a magnetic monopole candidate event by one of the Fairbank's graduate students, Blas Cabrera[2].  Cabrera was utilizing a loop type of magnetic monopole detector.  Its operation is in...

Cool Math Tricks: Deriving the Divergence, (Del or Nabla) into New (Cylindrical) Coordinate Systems

Now available as a Kindle ebook for 99 cents ! Get a spiffy ebook, and fund more physics The following is a pretty lengthy procedure, but converting the divergence, (nabla, del) operator between coordinate systems comes up pretty often. While there are tables for converting between common coordinate systems , there seem to be fewer explanations of the procedure for deriving the conversion, so here goes! What do we actually want? To convert the Cartesian nabla to the nabla for another coordinate system, say… cylindrical coordinates. What we’ll need: 1. The Cartesian Nabla: 2. A set of equations relating the Cartesian coordinates to cylindrical coordinates: 3. A set of equations relating the Cartesian basis vectors to the basis vectors of the new coordinate system: How to do it: Use the chain rule for differentiation to convert the derivatives with respect to the Cartesian variables to derivatives with respect to the cylindrical variables. The chain ...

More Cowbell! Record Production using Google Forms and Charts

First, the what : This article shows how to embed a new Google Form into any web page. To demonstrate ths, a chart and form that allow blog readers to control the recording levels of each instrument in Blue Oyster Cult's "(Don't Fear) The Reaper" is used. HTML code from the Google version of the form included on this page is shown and the parts that need to be modified are highlighted. Next, the why : Google recently released an e-mail form feature that allows users of Google Documents to create an e-mail a form that automatically places each user's input into an associated spreadsheet. As it turns out, with a little bit of work, the forms that are created by Google Docs can be embedded into any web page. Now, The Goods: Click on the instrument you want turned up, click the submit button and then refresh the page. Through the magic of Google Forms as soon as you click on submit and refresh this web page, the data chart will update immediately. Turn up the:...