new MousePosition
Create a new control to show the position of the mouse in the map's projection (or any other supplied projection). By default the control is shown in the top right corner of the map but this can be changed by using a css selector .ol-mouse-position.
Example:
var map = new ol.Map({
controls: ol.control.defaults({}, [
new ol.control.MousePosition({projection: ol.proj.get('EPSG:4326')})
]),
...
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
options |
ol.control.MousePositionOptions |
<optional> |
(Optional) Mouse position options. |
- Source:
- mousepositioncontrol.js, line 49
Extends
Methods
-
bindTo
-
Binds a View to a Model.
Parameters:
Name Type Argument Description key
string Key.
target
ol.Object Target.
targetKey
string <optional>
(Optional) Target key.
noNotify
boolean <optional>
(Optional) No notify.
- Inherited From:
- Source:
- object.js, line 147
-
get
-
Gets a value.
Parameters:
Name Type Description key
string Key.
- Inherited From:
- Source:
- object.js, line 170
Returns:
Value.
- Type
- *
-
getCoordinateFormat
-
- Source:
- mousepositioncontrol.js, line 140
Returns:
projection.
- Type
- ol.CoordinateFormatType | undefined
-
getMap
-
Get the map associated with this control.
- Inherited From:
- Source:
- control.js, line 69
Returns:
Map.
- Type
- ol.Map
-
getProjection
-
- Source:
- mousepositioncontrol.js, line 153
Returns:
projection.
- Type
- ol.Projection | undefined
-
handleMapPostrender
-
Function called on each map render. Executes in a requestAnimationFrame callback. Can be implemented in sub-classes to re-render the control's UI.
Parameters:
Name Type Description mapEvent
ol.MapEvent Map event.
- Inherited From:
- Source:
- control.js, line 80
-
notify
-
Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to.
Parameters:
Name Type Description key
string Key.
- Inherited From:
- Source:
- object.js, line 208
-
on
-
Listen for a certain type of event.
Parameters:
Name Type Argument Description type
string | Array.<string> The event type or array of event types.
listener
Function The listener function.
scope
Object <optional>
(Optional) Object is whose scope to call the listener.
- Inherited From:
- Source:
- object.js, line 240
Returns:
Unique key for the listener.
- Type
- goog.events.Key
-
once
-
Listen once for a certain type of event.
Parameters:
Name Type Argument Description type
string | Array.<string> The event type or array of event types.
listener
Function The listener function.
scope
Object <optional>
(Optional) Object is whose scope to call the listener.
- Inherited From:
- Source:
- object.js, line 253
Returns:
Unique key for the listener.
- Type
- goog.events.Key
-
set
-
Sets a value.
Parameters:
Name Type Description key
string Key.
value
* Value.
- Inherited From:
- Source:
- object.js, line 263
-
setCoordinateFormat
-
Parameters:
Name Type Description format
ol.CoordinateFormatType Coordinate format.
- Source:
- mousepositioncontrol.js, line 206
-
setMap
-
Remove the control from its current map and attach it to the new map. Subclasses may set up event handlers to get notified about changes to the map here.
Parameters:
Name Type Description map
ol.Map Map.
- Inherited From:
- Source:
- control.js, line 89
-
setProjection
-
Parameters:
Name Type Description projection
ol.Projection Projection.
- Source:
- mousepositioncontrol.js, line 218
-
setValues
-
Sets a collection of key-value pairs.
Parameters:
Name Type Description values
Object.<string, *> Values.
- Inherited From:
- Source:
- object.js, line 286
-
un
-
Unlisten for a certain type of event.
Parameters:
Name Type Argument Description type
string | Array.<string> The event type or array of event types.
listener
Function The listener function.
scope
Object <optional>
(Optional) Object is whose scope to call the listener.
- Inherited From:
- Source:
- object.js, line 326
-
unbind
-
Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed.
Parameters:
Name Type Description key
string Key.
- Inherited From:
- Source:
- object.js, line 305
-
unbindAll
-
Removes all bindings.
- Inherited From:
- Source:
- object.js, line 344
-
unByKey
-
Removes an event listener which was added with listen() by the key returned by on().
Parameters:
Name Type Argument Description key
number <nullable>
Key.
- Inherited From:
- Source:
- object.js, line 336