dojox/geo/openlayers/Map (version 1.10)

Summary

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:

Note that access to commercial server such as Google, Virtual Earth or Yahoo may need specific licencing.

The parameters value also include:

Usage

var foo = new Map(div,options);
dojox/geo/openlayers/Map
Parameter Type Description
div undefined
options undefined

See the dojox/geo/openlayers/Map reference documentation for more information.

Examples

Example 1

var map = new dojox.geo.openlayers.widget.Map(div, {
    baseLayerType: dojox.geo.openlayers.BaseLayerType.OSM,
    baseLayerName: 'Open Street Map Layer'
});

Property Summary

  • _tp
  • olMapThe underlying OpenLayers.Map object.

Method Summary

  • _createBaseLayer(params) Creates the base layer.
  • _getLayer(ol) Retrieve the dojox.geo.openlayer.Layer from the OpenLayer.Layer
  • addLayer(layer) Add the specified layer to the map.
  • fitTo(o) Fits the map on a point,or an area
  • getBaseLayerType() Returns the base layer type.
  • getLayer(property,value) Returns the layer whose property matches the value.
  • getLayerCount() Returns the count of layers of this map.
  • getOLMap() gets the underlying OpenLayers map object.
  • getScale(geodesic) Returns the current scale
  • initialFit(params) Performs an initial fit to contents.
  • layerIndex(layer,index) Set or retrieve the layer index.
  • removeLayer(layer) Remove the specified layer from the map.
  • setBaseLayerType(type) Set the base layer type, replacing the existing base layer
  • transform(p,from,to) Transforms the point passed as argument, expressed in the from coordinate system to the map coordinate system.
  • transformXY(x,y,from,to) Transforms the coordinates passed as argument, expressed in the from coordinate system to the map coordinate system.

Properties

_tp
olMap

The underlying OpenLayers.Map object. Should be accessed on read mode only.

Methods

_createBaseLayer(params)

Creates the base layer.

Parameter Type Description
params undefined
Returns:instance
_getLayer(ol)

Retrieve the dojox.geo.openlayer.Layer from the OpenLayer.Layer

Parameter Type Description
ol OpenLayer.Layer
Returns:undefined | null
addLayer(layer)

Add the specified layer to the map.

Parameter Type Description
layer dojox/geo/openlayers/Layer

The layer to add to the map.

fitTo(o)

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

Example 1

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.

getBaseLayerType()

Returns the base layer type.

Returns:any | undefined

The current base layer type.

getLayer(property,value)

Returns the layer whose property matches the value.

Parameter Type Description
property String

The property to check

value Object

The value to match

Returns:any | instance

The layer(s) matching the property's value. Since multiple layers match the property's value the return value is an array.

Examples

Example 1

var layers = map.getLayer("name", "Layer Name");

getLayerCount()

Returns the count of layers of this map.

Returns:any | number | undefined

The number of layers of this map.

getOLMap()

gets the underlying OpenLayers map object.

Returns:any | undefined

The underlying OpenLayers map object.

getScale(geodesic)

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.

Returns:null | undefined
initialFit(params)

Performs an initial fit to contents.

Parameter Type Description
params undefined
layerIndex(layer,index)

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

Returns:any | undefined | int

the index of the layer.

removeLayer(layer)

Remove the specified layer from the map.

Parameter Type Description
layer dojox/geo/openlayers/Layer

The layer to remove from the map.

setBaseLayerType(type)

Set the base layer type, replacing the existing base layer

Parameter Type Description
type dojox/geo/openlayers.BaseLayerType

base layer type

Returns:any | null | undefined

The newly created layer.

transform(p,from,to)

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
Returns:undefined
transformXY(x,y,from,to)

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.

Returns:any | undefined

The transformed coordinate as an {x,y} Object.

Error in the documentation? Can’t find what you are looking for? Let us know!