origo-map / origo

Origo
Other
48 stars 53 forks source link

Sharemap doesn't work when configuration is defined inline. #1927

Open huggla opened 9 months ago

huggla commented 9 months ago

The sharemap control is able to save the mapstate, but the given link doesn't retrieve it. Works when config is stored in separate json file.

<html>
    <head>
        <link href='css/style.css' rel='stylesheet'>
        <script src="js/origo.min.js"></script>
        <script>
            var json={
                "controls": [
                    {
                        "name":"mapmenu",
                        "options":{
                            "isActive":true
                        }
                    },
                    {
                        "name":"sharemap",
                        "options":{
                            "title":"Dela karta",
                                "storeMethod": "saveStateToServer",
                            "serviceEndpoint": "../origoserver/mapstate"
                        }
                    }
                ],
                "projectionCode": "EPSG:3857",
                "extent": [
                    -20026376.39,
                    -20048966.1,
                    20026376.39,
                    20048966.1
                ],
                "center": [
                    1770000,
                    8770000
                ],
                "resolutions": [
                    1222.99
                ],
                "layers": [{
                    "name": "osm",
                    "title": "OpenStreetMap",
                    "type": "OSM",
                    "visible": true
                }]
            };
        </script>
    </head>
    <body>
        <div id="app-wrapper"></div>
        <script>
            var origo = Origo(json);
        </script>   
    </body>
</html>
huggla commented 6 months ago

Could someone please take a look at this issue? It breaks some features in our Origo administration tool.

mulfvik commented 3 months ago

@huggla I cant reproduce this, is it still an issue?

huggla commented 3 months ago

Yes, still an issue.

To reproduce:

  1. Load the html above (no .json-file).
  2. Pan the map to new location.
  3. Create url with the sharemap tool "Dela karta".
  4. Open the url and notice that the map is loaded at the default location, not the location you paned to in step 2.

The created url from step 3 loads the correct location if you change the html to load the config from separate .json-file (don't need to recreate the mapstate).

Example contents of mapstate-*.json created in step 3: {"layers":["osm/v/1/s/0/o/100"],"center":"-1160384,7049863","zoom":"0","controls":{}}