11 Replies Latest reply on Jun 9, 2017 3:32 AM by makerbert

    anyone using openlayers (ol.js) for displaying multipolygons?

    makerbert

      I try to use openlayers (ol.js) to display a map in my webviewer (I have been let to believe it is better at displaying multipolygons in wkt (well known text) format which I intend to use a lot.

      I tried below code (sample from openlayers.org) which shows up nicely in both internet explorer and chrome but not in my webviewer (fm pro advanced 15.03.305)

       

      <!doctype html>
      <html lang="en">
        <head>
            <title>OpenLayers example</title>
          <link rel="stylesheet" href="https://openlayers.org/en/v4.1.0/css/ol.css" type="text/css">
        <script src="https://openlayers.org/en/v4.1.0/build/ol.js" type="text/javascript"></script>
          
        <style>
            #map {
              height: 200px;
              width: 300px;
            }
          </style>
          
        </head>
        <body>
          <h2>My Map</h2>
          <div id="map" class="map"></div>
          <h3>end of map</h3>
          <script type="text/javascript">
            var map = new ol.Map({
              target: 'map',
              layers: [
                new ol.layer.Tile({
                  source: new ol.source.OSM()
                })
              ],
              view: new ol.View({
                center: ol.proj.fromLonLat([37.41, 8.82]),
                zoom: 4
              })
            });
          </script>
        </body>
      </html>
      

       

      Anyone any idea as why this code won't show the basemap as it does in both IE and chrome?

       

      A similar page in leaflet.js works nicely but that doesn't seem to be capable of multipolygons ...

       

      Regards, thanks for reading, Bert

        • 1. Re: anyone using openlayers (ol.js) for displaying multipolygons?
          Malcolm

          I took your code, replaced all double quotes with single quotes, then put pasted that between double quotes in a web viewer. It looks OK to me.

           

          • 2. Re: anyone using openlayers (ol.js) for displaying multipolygons?
            user19752

            I confirmed it works (on Windows7), but prefer adding scheme "data:text/html," before your code.

             

            It looks the behavior without scheme had changed.

            Help in FM14 says

            begins with the correct scheme — for example, http://, https://, ftp://, gopher://, or file://. If you omit the scheme, the operating system’s web browser might use one that you didn’t intend.

            and "If you" sentence is removed from FM15, on Windows working as if there is data: (open temp file fm....htm) without description.

            • 3. Re: anyone using openlayers (ol.js) for displaying multipolygons?
              makerbert

              Hello Malcom, thank you for your comment but I think I might misunderstand you. Replacing double quotes with single quotes is easy enough but what do you mean by '... then put pasted that between double quotes ...'?

               

              I tried to quote everything between double quotes: "<!doctype html .... </html" but that resulted in the text "Loading..." in the bottom of the webviewer or an informational screen with the text "The address is not valid.

              • 4. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                makerbert

                The problem was worked around when I noticed an additional javascript used in anothe example at openlayers.org:

                 

                    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
                    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
                

                 

                So now I have

                 

                <!DOCTYPE html>
                <html lang='en'>
                  <head>
                      <title>OpenLayers example</title>
                    <link rel='stylesheet' href='https://openlayers.org/en/v4.1.0/css/ol.css' type='text/css'>
                <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
                <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
                  <script src='https://openlayers.org/en/v4.1.0/build/ol.js' type='text/javascript'></script>
                    
                  <style>
                      #map {
                        height: 200px;
                        width: 300px;
                      }
                    </style>
                    
                  </head>
                  <body>
                    <h2>My Map</h2>
                    <div id='map' class='map'></div>
                    <h3>end of map</h3>
                    <script type='text/javascript'>
                      var map = new ol.Map({
                        target: 'map',
                        layers: [
                          new ol.layer.Tile({
                            source: new ol.source.OSM()
                          })
                        ],
                        view: new ol.View({
                          center: ol.proj.fromLonLat([37.41, 8.82]),
                          zoom: 4
                        })
                      });
                    </script>
                  </body>
                </html>
                

                 

                And that works for me, more or less.

                 

                So, polyfill seems to translate some things so the user agent from the webviewer can render the map but reading the replies above it must be possible without. I'm tempted to mark it as answered but it this is not THE answer, more of a work around...

                 

                for the moment it will do.

                 

                Next step is to figure out how to render multipolygons read from my gis database. I'll keep you posted, thanks for your replies.

                • 5. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                  makerbert

                  I'm a bit weary of marking my own answer as 'answer' but the addition of the extra line/javascript did help me... Hope it helps more people. Geo in filemaker would be awesome!

                  • 6. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                    user19752

                    It is IE emulation version problem, so there is another solution.

                    Adding a line in <header> section.

                    <meta http-equiv='x-ua-compatible' content='ie=edge'/>

                    (I'd already edited windows registry for same effect)

                    2 of 2 people found this helpful
                    • 7. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                      makerbert

                      Great! This meta header works!

                      So now the first part of the file reads:

                       

                      "<!DOCTYPE html>
                      <html>
                      <head>
                        <meta http-equiv='x-ua-compatible' content='ie=edge'/>
                        <title>Clickable afdelingen KDHL</title>
                        <link rel='stylesheet' href='https://openlayers.org/en/v4.1.0/css/ol.css' type='text/css' />
                      </head>
                      <body>
                      and so on and so on ...
                      

                       

                      This weekend I learned that filemaker uses the browser from the underlaying operating system so behaviour of one and the same filemaker solution using webviewer can vary between iOS and windows.

                       

                      This complicates matter as I develop on a windows7 desktop but my solution will be used from iPad, but hey, if it was easy, everybody would be doing it ...

                       

                      Thanks user19752!

                      • 8. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                        beverly

                        but hey, if it was easy, everybody would be doing it ...

                        Add to the variations in the browsers, the 'ways of the web' change... daily sometimes is seems.

                         

                        Test your browser(s):

                        beverly

                        2 of 2 people found this helpful
                        • 9. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                          makerbert

                          Ok, This sample file aims at having the javascript, css and geojson locally in filemaker. This way I can control which version of openlayers & css is being used. Both JS and CSS work! but alas, I cannot get the geojson to show up.

                           

                          just one custom function which reads javascript, css and geojson from some related tables and shows a map made in openlayers.

                           

                          When I host the geojson on an external server the map works and shows the polygons (but unfortunately my clients don't have cellphone coverage when in the middle of the woods) So I want to read the geojson locally as well.

                           

                          Why can't I get the geojson to display in the custom function in the webviewer? I'm confused and would very much appreciate your input.

                          • 10. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                            user19752

                            I haven't got why the function does not work, but it downloads map from openstreetmap.org then wouldn't work without internet access.

                            • 11. Re: anyone using openlayers (ol.js) for displaying multipolygons?
                              makerbert

                              That's correct.

                               

                              But in openlayers it must be possible to use locally stored tiles so the next step would be to get those tiles locally (preferrably in FM) so I can read them.

                               

                              I read a book from packt publishers in which creating tiles and georeferencing those tiles is talked about, (openlayers 3.x beginners guide) Alas the book is somewhat outdated as openlayers is in active development, still a valuable read.

                               

                              For the moment my foresters would be happy to see the polygons without basemap as it would help them to know in which polygon they are.

                               

                              Thanks for your response!