Shareloc - the free and open map API based on OpenLayers
(Version 0.9.0)
Idea and development by
meggsimum
Shareloc
The Shareloc object provides a namespace for all elements of Shareloc
Shareloc.ApiCreatorApp
Application for the GUI based creation of Shareloc permalinks.
Shareloc.Layers
The class holding the layer configuration object. Also offers functions to access the layer objects of Shareloc.
Loads the JSON configuration stored at conf/layers.json
Shareloc.MapApi
This class represents the Shareloc map API.
It offers functions to create a customized OpenLayers map with a base layer by config as well as functions to add a marker and a popup to the map.
map(config)
Creates an OpenLayers map object by the given configuration object and renders it to a DIV with the ID 'map' in the DOM.
Configuration must be in the format:
{
X: 8.318049976895958,
Y: 49.43451657605041,
zoom: 14,
bgLayer: "opentopomap",
marker: "49.43707328904662,8.306307792663572",
popupText: "foo-popup-text"
}
parameter | type | description |
---|---|---|
config |
Object
|
the configuration object for the map |
ol.Map
:
the created OpenLayers map
marker(markerPosString)
Creates a marker feature on the map at the given position.
The position must be a comma separated String containing lat and lon, e. g. "49.43707328904662,8.306307792663572"
parameter | type | description |
---|---|---|
markerPosString |
String
|
the position where the marker is drawn |
ol.Feature
:
the created OpenLayers marker feature
markerPopup(markerFeat, popupText)
Creates a popup at the given feature's position
parameter | type | description |
---|---|---|
markerFeat |
ol.Feature
|
the marker feature to bin the popup to |
popupText |
String
|
the text to be shown in the popup |
Shareloc.Permalink
A class representing the permalink functionality of Shareloc.
createHash(map)
Creates the Shareloc URL hash representing the state of the given map. The following information is taken into account:
The has is returned in this form
map=14/49.43451657605041/8.318049976895958&layers=opentopomap
parameter | type | description |
---|---|---|
map |
ol.Map
|
the map to get the hash for |
String
:
the hash representing the map's state
createIframeCode(map)
Creates the Iframe code with the current Shareloc permalink
(derived by #createPermalinkUrl
of the given map as source. The size
of the Iframe defined by the current map size.
parameter | type | description |
---|---|---|
map |
ol.Map
|
the map to get the Iframe for |
String
:
the Iframe code representing the map
createPermalinkUrl(map)
Creates the Shareloc permalink URL representing the state of the given map. The following information is taken into account:
The has is returned in this form
http://myhost/share.html?zoom=14&X=8.318049976895958&Y=49.43451657605041&bgLayer=opentopomap&marker=49.43707328904662,8.306307792663572&popupText=foo-popup-text
parameter | type | description |
---|---|---|
map |
ol.Map
|
the map to get the permalink for |
String
:
the permalink representing the map's state
getFullHash
Returns the hash string of the underlying location.
String
:
the hash object
getHashObject
Returns a object representation of the hash string, e. g.:
{
zoom: 2,
X: 50.02345,
Y: 8.161234,
bgLayer: "osm.base"
}
The parameters 'X', 'Y' and 'zoom' are transformed to numbers.
Object
:
object holding the key-value-pairs of the hash
getParams
Returns the URL parameters of the underlying location, e.g.:
{
X: 8.318049976895958,
Y: 49.43451657605041,
zoom: 14,
bgLayer: "opentopomap",
marker: "49.43707328904662,8.306307792663572",
popupText: "foo-popup-text"
}
The parameters 'X', 'Y' and 'zoom' are transformed to numbers, all others remain strings.
Object
:
object holding the key-value-pairs of the URL params
VERSION
The current version of Shareloc