A map viewer based on the OpenLayers library.
The dojox.geo.openlayers.Map
object allows to view maps from various map providers.
It encapsulates an OpenLayers.Map
object on which most operations are delegated.
GFX layers can be added to display GFX georeferenced shapes as well as Dojo widgets.
Parameters can be passed as argument at construction time to define the base layer
type and the base layer parameters such as url or options depending on the type
specified. These parameters can be any of:
baseLayerType: type of the base layer. Can be any of:
dojox.geo.openlayers.BaseLayerType.OSM
: Open Street Map base layerdojox.geo.openlayers.BaseLayerType.Transport
: Open Street Map Transport base layer (opencyclemap.org)dojox.geo.openlayers.BaseLayerType.WMS
: Web Map Service layerdojox.geo.openlayers.BaseLayerType.GOOGLE
: Google layerdojox.geo.openlayers.BaseLayerType.VIRTUAL_EARTH
: Virtual Earth layerdojox.geo.openlayers.BaseLayerType.BING
: Bing layerdojox.geo.openlayers.BaseLayerType.YAHOO
: Yahoo layerdojox.geo.openlayers.BaseLayerType.ARCGIS
: ESRI ArgGIS layerNote that access to commercial server such as Google, Virtual Earth or Yahoo may need specific licencing.
The parameters value also include:
baseLayerName
: The name of the base layer.baseLayerUrl
: Some layer may need an url such as Web Map ServerbaseLayerOptions
: Additional specific options passed to OpensLayers layer,
such as The list of layer to display, for Web Map Server layer.Parameter | Type | Description |
---|---|---|
div | undefined | |
options | undefined |
See the dojox/geo/openlayers/Map reference documentation for more information.
var map = new dojox.geo.openlayers.widget.Map(div, { baseLayerType: dojox.geo.openlayers.BaseLayerType.OSM, baseLayerName: 'Open Street Map Layer' });
The underlying OpenLayers.Map object. Should be accessed on read mode only.
Creates the base layer.
Parameter | Type | Description |
---|---|---|
params | undefined |
Retrieve the dojox.geo.openlayer.Layer from the OpenLayer.Layer
Parameter | Type | Description |
---|---|---|
ol | OpenLayer.Layer |
Add the specified layer to the map.
Parameter | Type | Description |
---|---|---|
layer | dojox/geo/openlayers/Layer | The layer to add to the map. |
Fits the map on a point,or an area
Fits the map on the point or extent specified as parameter.
Parameter | Type | Description |
---|---|---|
o | Object | Object with key values fit parameters or a JSON string. |
Examples of arguments passed to the fitTo function:
null
The map is fit on full extent
{ bounds: [ulx, uly, lrx, lry] }
The map is fit on the specified bounds expressed as decimal degrees latitude and longitude.
The bounds are defined with their upper left and lower right corners coordinates.
{ position: [longitude, latitude], extent: degrees }
The map is fit on the specified position showing the extent <extent>
around
the specified center position.
Returns the base layer type.
The current base layer type.
Returns the layer whose property matches the value.
Parameter | Type | Description |
---|---|---|
property | String | The property to check |
value | Object | The value to match |
The layer(s) matching the property's value. Since multiple layers match the property's value the return value is an array.
var layers = map.getLayer("name", "Layer Name");
Returns the count of layers of this map.
The number of layers of this map.
gets the underlying OpenLayers map object.
The underlying OpenLayers map object.
Returns the current scale
Parameter | Type | Description |
---|---|---|
geodesic | Boolean | Tell if geodesic calculation should be performed. If set to true, the scale will be calculated based on the horizontal size of the pixel in the center of the map viewport. |
Performs an initial fit to contents.
Parameter | Type | Description |
---|---|---|
params | undefined |
Set or retrieve the layer index.
Set or get the layer index, that is the z-order of the layer. if the index parameter is provided, the layer index is set to this value. If the index parameter is not provided, the index of the layer is returned.
Parameter | Type | Description |
---|---|---|
layer | dojox/geo/openlayers/Layer | the layer to retrieve the index. |
index | int |
Optional index of the layer |
the index of the layer.
Remove the specified layer from the map.
Parameter | Type | Description |
---|---|---|
layer | dojox/geo/openlayers/Layer | The layer to remove from the map. |
Set the base layer type, replacing the existing base layer
Parameter | Type | Description |
---|---|---|
type | dojox/geo/openlayers.BaseLayerType | base layer type |
The newly created layer.
Transforms the point passed as argument, expressed in the from coordinate system to the map coordinate system.
Transforms the point passed as argument without modifying it. The point is supposed to be expressed in the from coordinate system and is transformed to the map coordinate system.
Parameter | Type | Description |
---|---|---|
p | undefined | The point to transform |
from | OpenLayers.Projection | The projection in which the point is expressed. |
to | undefined |
Transforms the coordinates passed as argument, expressed in the from coordinate system to the map coordinate system.
Transforms the coordinates passed as argument. The coordinate are supposed to be expressed in the from coordinate system and are transformed to the map coordinate system.
Parameter | Type | Description |
---|---|---|
x | Number | The longitude coordinate to transform. |
y | Number | The latitude coordinate to transform. |
from | OpenLayers.Projection |
Optional The projection in which the point is expressed, or EPSG4326 is not specified. |
to | OpenLayers.Projection |
Optional The projection in which the point is converted to. In not specifed, the map projection is used. |
The transformed coordinate as an {x,y} Object.