- center([options])
- down([delta])
- layers([options])
- legend([options])
- mapQuery([options])
- mqFeatureInfo([options])
- mqLayerControl([options])
- mqLayerManager([options])
- mqMousePosition([options])
- mqOverviewMap([options])
- mqPopup([options])
- mqZoomButtons([options])
- mqZoomSlider([options])
- opacity([opacity])
- pan(dx, dy)
- pixelsFromPosition(x, y)
- position([position])
- remove()
- up([delta])
- visible([visible])
- zindex()
- {type:bing}
- {type:google}
- {type:json}
- {type:osm}
- {type:tms}
- {type:vector}
- {type:wms}
- {type:wmts}
jquery.mapquery.core.js
The main MapQuery file. It contains the MapQuery constructor, the MapQuery.Map constructor and the MapQuery.Layer constructor.
$('selector').mapQuery([options])
version added 0.1
Description: initialise MapQuery and associate it with
the matched element options an object of key-value pairs with options for the map. Possible pairs are:
- layers (array of MapQuery.Layer or MapQuery.Layer): Either an array or a single layer that should be added to the map
- center ({position: [x,y], zoom: z(int), box: [llx,lly,urx,ury]}):
Initially go to a certain location. At least one layer (in the
layersoption) needs to be specified.Returns: $('selector') (jQuery object)
var map = $('#map').mapQuery(); //create an empty map
var map = $('#map').mapQuery({layers:[{type:'osm'}]); //create a map with osm
var mq = map.data('mapQuery'); //get the MapQuery object
MapQuery.Map
The MapQuery.Map object. It is automatically constructed from the options given in the `mapQuery([options])` constructor. The Map object is refered to as _map_ in the documentation.map.layers([options])
_version added 0.1_
Description: get/set the layers of the map
**options** an object of key-value pairs with options to create one or more layersThe `.layers()` method allows us to attach layers to a mapQuery object. It takes an options object with layer options. To add multiple layers, create an array of layer options objects. If an options object is given, it will return the resulting layer(s). We can also use it to retrieve all layers currently attached to the map.Returns: [layer] (array of MapQuery.Layer)
var osm = map.layers({type:'osm'}); //add an osm layer to the map
var layers = map.layers(); //get all layers of the map
map.center([options])
_version added 0.1_
Description: get/set the extent, zoom and position of the map
- position the position as [x,y] in displayProjection (default EPSG:4326) to center the map at
- zoom the zoomlevel as integer to zoom the map to
- box an array with the lower left x, lower left y, upper right x, upper right y to zoom the map to, this will take precedent when conflicting with any of the above values
- projection the projection the coordinates are in, default is
the displayProjection
Returns: {position: [x,y], zoom: z(int), box: [llx,lly,urx,ury]}
.center() method allows us to move to map to a specific zoom level,
specific position or a specific extent. We can specify the projection of the
coordinates to override the displayProjection. For instance you want to show
the coordinates in 4326, but you have a dataset in EPSG:28992
(dutch projection). We can also retrieve the current zoomlevel, position and
extent from the map. The coordinates are returned in displayProjection.
var center = map.center(); //get the current zoom, position and extent
map.center({zoom:4}); //zoom to zoomlevel 4
map.center({position:[5,52]}); //pan to point 5,52
map.center(box:[-180,-90,180,90]); //zoom to the box -180,-900,180,90
//pan to point 125000,485000 in dutch projection
map.center({position:[125000,485000],projection:'EPSG:28992'});
MapQuery.Layer
The MapQuery.Layer object. It is constructed with layer options object in the map.`layers([options])` function or by passing a `layer:{options}` object in the `mapQuery()` constructor. The Layer object is refered to as _layer_ in the documentation.layer.down([delta])
_version added 0.1_
Description: move the layer down in the layer stack of the map
- delta the amount of layers the layer has to move down in the layer
stack (default 1)
Returns layer (MapQuery.Layer)
.down() method is a shortcut method for .position(pos) which makes
it easier to move a layer down in the layerstack relative to its current
position. It takes an integer and will try to move the layer down the number of
places given. If delta is bigger than the current position in the stack, it
will put the layer at the bottom.
layer.down(); //move layer 1 place down
layer.down(3); //move layer 3 places down
layer.remove()
_version added 0.1_
Description: remove the layer from the map
The `.remove()` method allows us to remove a layer from the map. It returns an id to allow widgets to remove their references to the destroyed layer.Returns: id (string)
var id = layer.remove(); //remove this layer
layer.position([position])
_version added 0.1_
Description: get/set the position of the layer in the layer
stack of the map
- position an integer setting the new position of the layer in the layer stack
Returns: position (integer)
.position() method allows us to change the position of the layer in the
layer stack. It will take into account the hidden baselayer that is used by
OpenLayers. The lowest layer is position 0. If no position is given, it will
return the current postion.
var pos = layer.position(); //get position of layer in the layer stack
layer.position(2); //put layer on position 2 in the layer stack
layer.up([delta])
_version added 0.1_
Description: move the layer up in the layer stack of the map
- delta the amount of layers the layer has to move up in the layer
stack (default 1)
Returns: layer (MapQuery.Layer)
.up() method is a shortcut method for .position(pos) which makes
it easier to move a layer up in the layerstack relative to its current
position. It takes an integer and will move the layer up the number of places
given.
layer.up(); //move layer 1 place up
layer.up(3); //move layer 3 places up
layer.visible([visible])
_version added 0.1_
Description: get/set the visible state of the layer
- visible a boolean setting the visibiliyu of the layer
Returns: visible (boolean)
.visible() method allows us to change the visibility of the layer.
If no visible is given, it will return the current visibility.
var vis = layer.visible(); //get the visibility of layer
layer.visible(true); //set visibility of layer to true
layer.opacity([opacity])
_version added 0.1_
Description: get/set the opacity of the layer
- position a float [0-1] setting the opacity of the layer
Returns: opacity (float)
.opacity() method allows us to change the opacity of the layer.
If no opacity is given, it will return the current opacity.
var opac = layer.opacity(); //get opacity of layer
layer.opacity(0.7); //set opacity of layer to 0.7
layer {type:bing}
_version added 0.1_
Description: create a Bing maps layer
- view a string ['road','hybrid','satellite'] to define which Bing maps layer to use (default road)
- key Bing Maps API key for your application. Get you own at http://bingmapsportal.com/
label string with the name of the layer
layers:[{ type:'bing', //create a bing maps layer view:'satellite', //use the bing satellite layer key:'ArAGGPJ16xm0RX' //the Bing maps API key }]
layer {type:google}
version added 0.1
Description: create a Google maps layer
- view a string ['road','hybrid','satellite'] to define which Google maps layer to use (default road)
- label string with the name of the layer
Note you need to include the google maps v3 API in your application by adding
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"type="text/javascript"></script>
layers:[{
type:'google', //create a google maps layer
view:'hybrid' //use the google hybridlayer
}]
layer {type:vector}
version added 0.1
Description: create a vector layer
label string with the name of the layer
layers:[{ type:'vector' //create a vector layer }]
layer {type:json}
version added 0.1
Description: create a JSON layer
- url a string pointing to the location of the JSON data
- strategies a string ['bbox','cluster','filter','fixed','paging','refresh','save'] stating which update strategy should be used (default fixed) (see also http://dev.openlayers.org/apidocs/files/OpenLayers/Strategy-js.html)
- projection a string with the projection of the JSON data (default EPSG:4326)
- styleMap {object} the style to be used to render the JSON data
label string with the name of the layer
layers:[{ type: 'JSON', url: 'data/reservate.json', label: 'reservate' }]
layer {type:osm}
version added 0.1
Description: create an OpenStreetMap layer
- label string with the name of the layer
- url A single URL (string) or an array of URLs to OSM-like server like Cloudmade
attribution A string to put some attribution on the map
layers:[{ type: 'osm', url: [ 'http://a.tile.cloudmade.com/
/999/256/${z}/${x}/${y}.png', 'http://b.tile.cloudmade.com/ /999/256/${z}/${x}/${y}.png', 'http://c.tile.cloudmade.com/ /999/256/${z}/${x}/${y}.png' ], attribution: "Data © 2009 OpenStreetMap. Rendering © 2009 CloudMade." }]
layer {type:tms}
version added 0.1
Description: create an OpenStreetMap layer
- label string with the name of the layer
- url A single URL (string) or an array of URLs to the TMS end point
- layer The identifier for the
as advertised by the service. For example, if the service advertises a with ‘href=”http://tms.osgeo.org/1.0.0/vmap0”’, the layer property would be set to “vmap0”. format The image format (default png)
layers:[{ type: 'tms', url: 'http://tilecache.osgeo.org/wms-c/Basic.py/', layer: 'basic' }]
layer {type:wms}
version added 0.1
Description: create a WMS layer
- url a string pointing to the location of the WMS service
- layers a string with the name of the WMS layer(s)
- format a string with format of the WMS image (default image/jpeg)
- transparent a boolean for requesting images with transparency
- label string with the name of the layer
wms_parameters an hashtable of extra GetMap query string parameters and parameter values
layers:[{ type:'wms', url:'http://vmap0.tiles.osgeo.org/wms/vmap0', layers:'basic' }]
layer {type:wmts}
version added 0.1
Description: create a WMTS (tiling) layer
- url a string pointing to the location of the WMTS service
- layer a string with the name of the WMTS layer
- matrixSet a string with one of the advertised matrix set identifiers
- style a string with one of the advertised layer styles
label string with the name of the layer
layers:[{ type:'wmts' }]
