bcgov / smk-legacy-ui

Legacy Admin UI for the SMK has been de-supported. Please see the CLI under https://github.com/bcgov/smk for an alternative.
Apache License 2.0
8 stars 3 forks source link

Startup Parameters #39

Open NicoledeGreef opened 6 years ago

NicoledeGreef commented 6 years ago

Support startup parameters to control:

Search by attribute(s) ability to set an extent and zoom level on the fly mapOnly Chainable (i.e. Add Layer 43, query features from layer 43, zoom to the features) Feature suppression (even if the widgets are configured, provide the ability to omit them via URL params)

cpspicer commented 6 years ago

Examples can be provided. Moving to sprint 2

qqnluaq commented 6 years ago

The query parameters to the webpage are good for setting the initial state of the map:

Actions to be performed on the map after it starts are better done through a JS API. The Host application should be able to control the map as if a user was driving it.

cpspicer commented 6 years ago

Yes, would be nice to allow host page to drive the application.

In addition, we have use cases in the DMF whereby the user enters the app through a URL call that includes adding a map layer by number from the MPCM Layer service, selecting and zooming to a specific feature. Some old school government apps still use this approach to 'call' a map. Handy to allow one 'generic' app to serve hundreds of these use cases.

Full documentation on parameterized calls in the DMF is available, including URL syntax if it's useful.

qqnluaq commented 6 years ago

https://github.com/bcgov/smk/wiki/SMK-Client-API

cpspicer commented 6 years ago

I need some examples of how to zoom to a feature of a given layer. i.e. ALR Polygons layer, feature attribute 'ALR_Poly_ID' and feature value of '2854196'. See initial use cases at the start of this thread. Docs are a good start - but I need some practical examples I can manipulate for testing.

e.g. URL to an app/?smk... ??

cpspicer commented 6 years ago

Nicole - can you please also do some testing, based on instructions provided to date. Ty.

NicoledeGreef commented 6 years ago

i think i need more guidance in terms of syntax. i have tried and failed:

http://smk.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=cfis&center=-111.22558593750001,49.009050809382074,8

http://smk.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=cfis&center=[-111.22558593750001],[49.009050809382074],[8]

Also, based on the notes above, I don't see an option for querying a pre-configured layer or for adding an MPCM layer on the fly and querying that.

Lastly the mapOnly ask - this is for embedding in other webpages when you just want a small map and no banner.

qqnluaq commented 6 years ago

Center on location

https://smk-demo.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=ben-7&smk-center=-123.7193,48.3903,12

Activate directions tool

https://smk-demo.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=ben-7&smk-active-tool=directions

Disable the directions tool

https://smk-demo.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=ben-7&smk-config={"tools":[{"type":"directions","enabled":false}]}

Activate query tool

https://smk-demo.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=ben-7&smk-active-tool=query--746--query1

Activate query tool, set parameter

https://smk-demo.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=ben-7&smk-active-tool=query--746--query1&smk-config={"layers":[{"id":746,"queries":[{"id":"query1","parameters":[{"id":"param1","value":"Salmon"}]}]}]}

Activate query tool, set parameter, start query

https://smk-demo.pathfinder.gov.bc.ca/smk-ui/viewer.html?type=edit&id=ben-7&smk-active-tool=query--746--query1&smk-config={"layers":[{"id":746,"queries":[{"id":"query1","parameters":[{"id":"param1","value":"Salmon"}]}]}]}&smk-config={"tools":[{"type":"query","instance":"746--query1","onActivate":"execute"}]}

NicoledeGreef commented 6 years ago

Having reviewed the URL examples, it seems that there is currently lots of flexibility (through JSON-driven config) which is great but that lends itself to becoming more complex syntax.

By contrast, please refer to the DMF Features Guide: https://www2.gov.bc.ca/assets/gov/data/geographic/databc-mashup-framework/dmf_viewer_features_2_1_final.pdf

Section 3.3. contains details on how to query layers from the URL in DMF.

Myriad use cases across Gov involve the ability to embed a small map in a webpage, show data layer(s), query a layer based on attribute values, zoom to the extent of the results, highlight the results or filter based on the results....

Is there a syntax for adding a layer, or referencing a pre-configured layer, and querying by one or more attribute values, without invoking a query widget that displays in the UI?

cpspicer commented 6 years ago

Note on the last example, RE Query widget. If you close the query pane the results are removed from the map.

qqnluaq commented 6 years ago

I made notes on the startup parameters from above document, on how they can be implemented in SMK today.

3.3.1 Set the Map Extent

ll – latitude/longitude coordinate pair, separated by a comma .

z – map zoom level, range 0-21 where 0 is zoomed out.

smk-center sets the center, and optionally the zoom.

smk-extent sets the visible extent from a pair of coordinates.

There is no method at present to set the zoom without specifying the center.

3.3.2 Filter with Search by Category

qLayer – layer name, as defined in the DMF Wizard, to execute a search.

qWhere – search parameters, format {Field_Name} OP ’Value’ CONJ ….

  • Valid OPs: =, <, <=, >, >=, LIKE.
  • Valid CONJs: AND, OR (cannot mix).
  1. Use smk-config to modify the default parameters for a defined query. Alternatively, use smk-config to add a new query to an existing layer.

  2. Use smk-config to set the onActivate property on the query tool to execute so the query is invoked when it becomes active.

  3. Use smk-active-tool to activate the query tool.

3.3.3 Set the Layer Visibility

Use vertical bars (|) to separate the list elements.

lshow – list of layer names to SHOW on startup.

lhide – list of layer names to HIDE on startup (should not be combined with lshow).

Use smk-config to set the isVisible flag on any layer, given it's id.

There is no method to show or hide all layers, without knowing the specific ids.

3.3.4 Add Dynamic Data Sources

Use vertical bars (|) to separate the list elements.

wmsservices – list of WMS URLs to scan for WMS layers.

wmslayers – list of WMS layer names to include.

geomarks – list of geomark URLs.

Use smk-config to add any layers that are needed.

Support for Geomark layers is planned.

3.3.5 Other

maponly – shows only the map without the banner or any configured tasks. Disables feature selection in mobile browsers.

The <script> element that loads SMK is checked for an attribute called smk-standalone. If present, this attribute signals that the page loading SMK is going to under the control of SMK. If it is not present, SMK assumes it is being loaded as part of an other application.

In smk-standalone mode, the header is displayed.

Using smk-config, all the tools can be individually disabled.

hidetasks – in Desktop mode, hides the side panel by default, but keeps the ‘open panel’ tab available.

Use smk-config to disable all tools.

disableinfowindow – prevents the map from displaying feature data when user clicks on a feature.

Use smk-config to disable the identify tool.

lang – forces the map to display labels in a specific language. Valid language codes can be found on the Google Maps API Languages Coverage document.

No support in SMK for other languages.

dhlevi commented 6 years ago

I understand concerns about complexity. Using config snippets is reasonable for a developer to understand, but for a regular user it might be complicated. Plus, it can make a URL look pretty funky (only a problem for standalone mode).

We can create "helper" query commands that mimic DMF exactly, which will make using the query string simpler for a regular non-developer user. If that's desired, let us know and we'll add it to the MVP update list.

As far as query string length or ugliness, we can use tinyurl or something similar to encode and trim the querystring down to something reasonable, as an option.

cpspicer commented 6 years ago

Agree with creating helper query commands. Need support to add MPCM layer (hopefully via its ID). TinyURL support can be deferred for now. Will make a separate card for it.

qqnluaq commented 6 years ago

@cpspicer I just did some investigation on the problem of loading MPCM layers dynamically into SMK client. The MPCM service appears to be not be configured for CORS. I can make the request from the browser, and get back the correct response, but because the response is missing the Access-Control-Allow-Origin header, the browser blocks the request.

dhlevi commented 6 years ago

@cpspicer As per Bens note above: Our options here are to have MPCM update their CORS rules so we can get access to it from the browser, or run the request through a proxy. It works in the admin side because the service acts as our proxy, but an exported client will not have that as an option.

cboreen commented 6 years ago

@cpspicer I think Michelle has a proxy we can run this through that can add the CORS stuff.

qqnluaq commented 6 years ago

I've added this to wiki: https://github.com/bcgov/smk/wiki/Startup-Parameters It is up-to-date. I believe all options from DMF have an equivalent option in SMK now.

NicoledeGreef commented 6 years ago

is there currently a way to call the equivalent of "mapOnly" in DMF?

In DMF you can add mapOnly as a parameter when you want to suppress everything (banner, side panel, etc.) except the map; this is useful when you embed a map in another page as in: https://www.workbc.ca/Employment-Services/WorkBC-Centres/Find-your-WorkBC-Employment-Services-Centre-(1).aspx