A versatile and lightweight toolkit for building a simple web map.
This project is maintained by qqnluaq
This value controls the sources of configuration that are used to setup the map. These configuration sources are each ultimately resolved into an object that is interpreted by the SMK configuration schema.
The resolved configuration objects are merged together, and the final merged object is used to setup the map (merging rules).
The default value for the source directives is [ '?smk-' ]
, which tells SMK to look at the URL of the host page for any parameters that start with smk-
.
If this behaviour is undesirable, then the configuration source should be changed.
smk-config
AttributeNot required, default is “?smk-
”
Used by the SMK <script>
element.
It contains a list of source directives, separated by “|
”
The sources are loaded left to right, with the configuration from later sources overriding configuration from earlier sources.
A source directive cannot contain “|
”, and there is no escaping mechanism.
Example showing all types of directives:
<script src="smk/dist/smk.js" smk-container-sel="#smk-map-frame" smk-config="smk-config.json | {"viewer":{"baseMap":"Streets"}} | ?smk- | zoom=7" ></script>
config
OptionNot required, default is “[ '?smk-' ]
”
Used by SMK.INIT
.
The value is an array of source directives.
The sources are loaded left to right, with the configuration from later sources overriding configuration from earlier sources.
Example showing all types of directives:
SMK.INIT( { containerSel: '#smk-map-frame', config: [ 'smk-config.json', { viewer: { baseMap: 'Streets' } }, '?smk-', 'zoom=7' ] } )
A source directive is one of the following:
A valid URL that is assumed to point a file containing a JSON-encoded SMK configuration object.
SMK configuration as a literal JSON string. No newlines should be in the JSON, unless they are escaped inside quoted strings.
This is only useful in the smk-config
Attribute, and the JSON blob must be encoded by encodeURIComponent.
SMK configuration as a Javascript object literal.
This is only useful in the config
Option.
A sequence that start with ?
.
It may be followed by any character string, like ?smk-
, or ?foo
, or ?##
.
The characters following the ?
are the Prefix.
A ?
with nothing following, means that the Prefix is an empty string.
When this directive is encountered, the URL of the current document is parsed, and the parameter section is extracted.
The parameter section is parsed according to the usual rules (split by &
into items, and split each item by =
into [key, value] pairs). Then if a parameter key starts with the Prefix, the rest of the parameter key is considered to be an alias directive along with the parameter value.
A Prefix that is an empty string matches any parameter key.
A string consisting of an NAME
=
ARGUMENTS
.
These are aliases for a blob of SMK configuration.
The aliases always resolve to some chunk of SMK config.
The NAME
is one of:
config
Aliasconfig=
JSON-LITERAL
The JSON-LITERAL
is parsed as JSON that is assumed to be SMK configuration.
config=
URL
Fetch the resource at URL
that is assumed to be a SMK configuration JSON blob.
viewer
Aliasviewer=leaflet
Set the viewer type to leaflet.
viewer=esri3d
Set the viewer type to esri3d.
extent
Aliasextent=
MIN-LONGITUDE
,
MIN-LATITUDE
,
MAX-LONGITUDE
,
MAX-LATITUDE
Sets the initial extent of map.
center
Aliascenter=
LONGITUDE
,
LATITUDE
,
ZOOM
Sets the initial center point of the map, and the zoom level.
ll
Aliasll=
LONGITUDE
,
LATITUDE
Sets the initial center point of the map.
z
Aliasz=
ZOOM
Sets the initial zoom level of the map.
query
Aliasquery=
LAYER-ID
,and,
CLAUSE
[,
CLAUSE
]*query=
LAYER-ID
,or,
CLAUSE
[,
CLAUSE
]*
LAYER-ID
must refer to a layer defined in the "layers"
configuration.
CLAUSE
is one or more expressions of one of these forms (ATTRIBUTE
is an attribute name valid for the layer, and VALUE
is a JSON-encoded literal):
ATTRIBUTE
=
VALUE
(equals)ATTRIBUTE
~
VALUE
(contains)ATTRIBUTE
^~
VALUE
(starts with)ATTRIBUTE
$~
VALUE
(ends with)ATTRIBUTE
>
VALUE
(greater than)ATTRIBUTE
<
VALUE
(less than)ATTRIBUTE
>=
VALUE
(greater than or equal)ATTRIBUTE
<=
VALUE
(less than or equal)Mulitple clauses are joined with either and
or or
.
Configures a query object for the layer, and a matching "query"
tool with the auto-execute flag, and sets the tool automatically active at startup.
layer
Aliaslayer=esri-dynamic,
URL
,MPCM-ID
,
TITLE
(currently not functional)
Add a "esri-dynamic"
layer. TITLE
is optional.
layer=wms,
URL
,
LAYER-NAME
,
STYLE-NAME
,
TITLE
Add a "wms"
layer. STYLE-NAME
, and TITLE
are optional.
layer=vector,
URL
,
TITLE
Add a "vector"
layer. TITLE
is optional.
active-tool
Aliasactive-tool=
TOOL
,
INSTANCE
Make TOOL
active when the map starts.
INSTANCE
is optional.
show-tool
Aliasshow-tool=
TOOL
[,
TOOL
]*
Enable these TOOL
s.
show-tool=all
Enable all tools.
hide-tool
Aliashide-tool=
TOOL
[,
TOOL
]*
Disable these TOOL
s.
hide-tool=all
Disable all tools.
show-layer
Aliasshow-layer=
LAYER-ID
[,
LAYER-ID
]*
Set the visibility flag for the layers with these LAYER-ID
s to true
.
show-layer=all
Set the visibility flag for all configured layers to true
.
hide-layer
Aliashide-layer=
LAYER-ID
[,
LAYER-ID
]*
Set the visibility flag for the layers with these LAYER-ID
s to false
.
hide-layer=all
Set the visibility flag for all configured layers to false
.