Author Topic: How to incorporate an OpenStreetMap in your WeatherCat website.  (Read 1612 times)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6522
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
How to incorporate an OpenStreetMap in your WeatherCat website.
« on: February 11, 2022, 10:06:16 PM »
Dear WeatherCat user who like to be precise about where there are at,

A map of your weather station's location goes a long way toward orienting visitors to the data you are collecting.  There was a time when such information could be easily added to your website for free from Google.  However as reported elsewhere, Google has gone "corporate" with this service:

https://athena.trixology.com/index.php?topic=3368.msg32257#msg32257

My WeatherCat website is sadly overdue for some serious maintenance, but thanks to the thread noted above, I did resolve the issue of a broken map.  After doing a few rounds (or should I say futile loops) trying to understand Google's new rules, I decided to look elsewhere: OpenStreetMap.org.  This mapping service is open-source and thus completely free of all the corporate strings of it rivals.  The OpenStreetMap Wiki has all the basic instructions you really need:

https://wiki.openstreetmap.org/wiki/Export#Embeddable_HTML

However, there is some sage advice to be considered in switching.  My old Google map was fixed in resolution, so what was centered on didn't really matter.  What was displayed was most of the San Francisco Bay Area.   As will become clear shortly, this bit of sage advice from X-Air (from the same thread) is extremely relevant to OpenStreetMap:

Instead of publishing your exact home address, consider a more generic 'map' using a local police or fire station and have the 'map' cover several square miles of area. I don't include any map of our house location except where needed by a few of the "partners" I share my wx data with. And I notice that some of those tend to lose track of me, anyway. [rolleyes2]

With that notion in mind I decided to launch OpenStreetMap with the address of a nearby grammar school.

That this point you can simply follow the instructions in the OpenStreetMap Wiki which read as follows:

To embed OpenStreetMaps, you simply: Go to https://www.openstreetmap.org.
...
3. OpenStreetMap

    Navigate to the area you want to display.
    Click on the sharing button.
    Click the “HTML” option.
    Click “Add a marker to the map.”
    Copy the HTML text in the box (starts with <iframe).
    Past the code into your web app.


OpenStreetMap has a nice so-called Slippy map which is an active Ajax component Javascript that allows you to zoom, pan, and otherwise explore the map location.  That's helpful for the visitor, but if you provided your exact address, they could quite literally zoom in until they saw your home location - thus the wisdom in providing a nearby and public location instead.

There is one more bit of advice that isn't obvious from the OpenStreetMap documentation.  The display default of OpenStreetMap is a true square.  There are cases when a rectangle would be preferable.  In such cases it might not display as you expect.  To get a handle on how things would be displayed I created a small test HTML page to experiment with:

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Test of an embedded OpenStreetMap</title>
  </head>
  <body>
    <div align="center"><b>Test of an embedded OpenStreetMap</b><br>
    </div>
    <br>
    <iframe scrolling="no" marginheight="0" marginwidth="0"
src="https://www.openstreetmap.org/export/embed.html?bbox=-122.36881256103516%2C37.69658933039993%2C-121.93691253662111%2C37.99453932469732&amp;layer=mapnik"
      style="border: 1px solid black" frameborder="0" height="480"
      width="640"></iframe><br>
    <small><a
        href="https://www.openstreetmap.org/#map=12/37.8456/-122.1528">View
        Larger Map</a></small>
  </body>
</html>

You can view the test page here:

http://www.canebas.org/WeatherCat/Forum_support_documents/OpenStreetMap_test.html

I finally installed the new map on my existing website as can be seen here:

http://www.canebas.org/Weather/Canebas_region.html

So if your WeatherCat website doesn't have a map, or you want to change it to OpenStreetMap, it is a quick and easy upgrade to make.

Cheers, Edouard

Blicj11

  • Storm
  • *****
  • Posts: 3968
    • EW3808
    • KUTHEBER6
    • Timber Lakes Weather
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP Data Logger | iMac (2019), 3.6 GHz Intel Core i9, 40 GB RAM, macOS Ventura 13.6.7 | Sharx SCNC2900 Webcam | WeatherCat 3.3 | Supportive Wife
Re: How to incorporate an OpenStreetMap in your WeatherCat website.
« Reply #1 on: February 11, 2022, 11:43:35 PM »
Thank you for taking the time to provide a thorough walk-though. I've added a map to one of my sites. Hope you are feeling better.
Blick


elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6522
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Da' plot thickens . . . . (Re: How to incorporate an OpenStreetMap)
« Reply #2 on: February 12, 2022, 09:43:13 PM »
Dear Blick and WeatherCat web spinners,

Thank you for taking the time to provide a thorough walk-though. I've added a map to one of my sites.

You are most welcome!

Hope you are feeling better.

Well honestly not really.  My new nose is literally only about 1/3 complete.  In the meantime, what is there is quite fragile and unable to fully function as a nose.  As a result, I'm really vulnerable to sinus congestion.  I just have to muddle through until this process is complete.  Right now Northern California is having unusually hot and dry weather which is increasing air pollution levels.  Definitely not the best of circumstances to be dealing with this sort of condition.

However, there is something of a surprise change.  The professor (and surgeon) of UCSF who was doing these surgeries happened to also be an avid cyclist.  It turns out he had a bicycling accident and is out of action for 2-3 months!  An associate professor will be completing the remaining two surgeries.  I find myself in the curious position of needing to send a get-well card to my surgeon!

Cheers, Edouard

Blicj11

  • Storm
  • *****
  • Posts: 3968
    • EW3808
    • KUTHEBER6
    • Timber Lakes Weather
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP Data Logger | iMac (2019), 3.6 GHz Intel Core i9, 40 GB RAM, macOS Ventura 13.6.7 | Sharx SCNC2900 Webcam | WeatherCat 3.3 | Supportive Wife
Re: How to incorporate an OpenStreetMap in your WeatherCat website.
« Reply #3 on: February 12, 2022, 10:10:41 PM »
Dang! As a cyclist myself, I can only imagine how banged up he is to be out for that long. Hang in there.
Blick