georchestra / mapstore2-georchestra

geOrchestra newest viewer
Other
6 stars 23 forks source link

embed via API not possible #520

Open landryb opened 2 years ago

landryb commented 2 years ago

dunno if that's something that should work or wasnt planned (@catmorales @MaelREBOUX ?) but embedding mapstore via its API doesn't work.

i've enabled the feature by toggling showAPI to true in share plugin, that properly displays the 'via API' code: image

the resulting HTML is:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Page with MapStore API</title>
        <link rel="preconnect" href="https://fonts.gstatic.com">
        <link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css" />
        <link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
        <script src="https://maps.google.com/maps/api/js?v=3"></script>
        <!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>
        <style>
        #container {
            position: absolute;
            top: 100px;
            left: 100px;
            right: 100px;
            bottom: 100px;
        }
        #mapstore2-embedded, #map, .fill {
            width: 100%;
            height: 100%;
        }
        </style>
    </head>
    <body onload="init()">
        <div id="container" class="ms2"></div>
        <script id="ms2-api" src="https://georchestra.dev.craig.fr/mapstore/dist/ms2-api.js?2022.01.xx
2022.01.xx"></script>
        <script type="text/javascript">
        function init() {
            MapStore2.create('container',{
                configUrl: "https://georchestra.dev.craig.fr/mapstore/rest/geostore/data/",
                originalUrl: "https://georchestra.dev.craig.fr/mapstore/#/"
            });
        }
        </script>
    </body>
</html>

but this doesnt work as it refers to dist/ms2-api.js which isnt built/bundled in the WAR.

Anan0201 commented 1 year ago

Hey did you solve the issues? In my case i don't but i think the problem is related to the recent version of mapstore. To use mapstore API, you can try the mapstore version 2018.01.00. But i have not try it yet

check this article for more détails:https://github.com/geosolutions-it/MapStore2/issues/3211