Class M.MapView
Extends
M.View.
M.MapView is the prototype of a map view. It defines a set of methods for
displaying a map, setting markers and showing the current location. This
map view is based on google maps, but other implementations are possible.
Defined in: map.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
If set, contains the map view's callback in sub a object named 'error',
which will be called if no connection is available and the map service
(google maps api) can not be loaded.
|
|
This property specifies the initial location for this map view, as an M.Location
object.
|
|
This property specifies whether the map is draggable or not.
|
|
This property spacifies whether or not this map has already been initialized.
|
|
Determines whether to display the map view 'inset' or at full width.
|
|
This flag can be used to specify whether or not to load the google places
library.
|
|
This property is used to save a reference to the actual google map.
|
|
This property specifies the map type for this map view.
|
|
This property can be used to specify the animation type for this map view's
markers.
|
|
This property is used to store the map's M.MapMarkerViews.
|
|
This property specifies the recommended events for this type of view.
|
|
This property specifies whether or not to remove all existing markers on a
map update.
|
|
This property determines whether or not to show a marker at the map view's
initial location.
|
|
This property specifies whether or not to display the map type controls
inside of this map view.
|
|
This property specifies whether or not to display the navigation controls
inside of this map view.
|
|
This property specifies whether or not to display the street view controls
inside of this map view.
|
|
The type of this object.
|
|
This property specifies the zoom level for this map view.
|
- Fields borrowed from class M.View:
- childViews, computedValue, contentBinding, contentBindingReverse, cssClass, cssClassOnError, cssClassOnInit, cssStyle, events, hasFocus, html, id, isInline, isView, modelId, parentView, triggerActionOnChange, triggerActionOnEnter, triggerActionOnKeyUp, value
Method Attributes | Method Name and Description |
---|---|
addMarker(marker)
This method can be used to add a marker to the map view.
|
|
initMap(options, isUpdate)
This method is used to initialize a map view, typically out of a controller.
|
|
This method is responsible for registering events for view elements and its child views.
|
|
This method removes all markers from this map view.
|
|
removeMarker(marker)
This method can be used to remove a certain marker from the map view.
|
|
This method is called if the bound content changed.
|
|
updateMap(options)
This method is used to update a map view, typically out of a controller.
|
- Methods borrowed from class M.View:
- addCssClass, attachToObservable, clearHtml, clearValue, clearValues, computeValue, contentDidChange, delegateValueUpdate, design, getChildViewsAsArray, getIds, getValue, getValues, gotFocus, lostFocus, nl2br, removeCssClass, removeCssProperty, secure, setCssProperty, setValueFromDOM, style, tab2space, theme, themeChildViews
- Methods borrowed from class M.Object:
- bindToCaller, create, destroy, extend, get, include, set
Field Detail
{Object}
callbacks
If set, contains the map view's callback in sub a object named 'error',
which will be called if no connection is available and the map service
(google maps api) can not be loaded.
{M.Location}
initialLocation
This property specifies the initial location for this map view, as an M.Location
object. Its latitude and longitude properties are directly mapped to the center
property of a google map view. For further information see the google maps API
specification:
http://code.google.com/intl/en-US/apis/maps/documentation/javascript/reference.html#MapOptions
{Boolean}
isDraggable
This property specifies whether the map is draggable or not. If set to NO,
a user won't be able to move the map, respectively the visible sector. For
further information see the google maps API specification:
http://code.google.com/intl/en-US/apis/maps/documentation/javascript/reference.html#MapOptions
{Boolean}
isInitialized
This property spacifies whether or not this map has already been initialized.
{Boolean}
isInset
Determines whether to display the map view 'inset' or at full width.
{Boolean}
loadPlacesLibrary
This flag can be used to specify whether or not to load the google places
library. By default this property is set to YES. If you do not need the
library, you should set this to NO in order to save some bandwidth.
{Object}
map
This property is used to save a reference to the actual google map. It
is set automatically when the map is firstly initialized.
{String}
mapType
This property specifies the map type for this map view. It is directly
mapped to the 'mapTypeId' property of a google map view. Possible values
for this property are:
- M.MAP_ROADMAP --> This map type displays a normal street map.
- M.MAP_HYBRID --> This map type displays a transparent layer of major streets on satellite images.
- M.MAP_SATELLITE --> This map type displays satellite images.
- M.MAP_TERRAIN --> This map type displays maps with physical features such as terrain and vegetation.
For further information see the google maps API specification:
http://code.google.com/intl/en-US/apis/maps/documentation/javascript/reference.html#MapOptions
{String}
markerAnimationType
This property can be used to specify the animation type for this map view's
markers. The following three values are possible:
M.MAP_MARKER_ANIMATION_NONE --> no animation
M.MAP_MARKER_ANIMATION_DROP --> the marker drops onto the map
M.MAP_MARKER_ANIMATION_BOUNCE --> the marker constantly bounces
{Object}
markers
This property is used to store the map's M.MapMarkerViews. If a marker
is set within the init() method or by calling the addMarker() method,
it is automatically pushed into this array.
{Array}
recommendedEvents
This property specifies the recommended events for this type of view.
{Boolean}
removeMarkersOnUpdate
This property specifies whether or not to remove all existing markers on a
map update. A map update can either be an automatic update due to content
binding or a implicit call of the map view's updateMap() method.
{Boolean}
setMarkerAtInitialLocation
This property determines whether or not to show a marker at the map view's
initial location. This location can be specified by the initialLocation
property of this map view.
{Boolean}
showMapTypeControl
This property specifies whether or not to display the map type controls
inside of this map view. For further information see the google maps API
specification:
http://code.google.com/intl/en-US/apis/maps/documentation/javascript/reference.html#MapOptions
{Boolean}
showNavigationControl
This property specifies whether or not to display the navigation controls
inside of this map view. For further information see the google maps API
specification:
http://code.google.com/intl/en-US/apis/maps/documentation/javascript/reference.html#MapOptions
{Boolean}
showStreetViewControl
This property specifies whether or not to display the street view controls
inside of this map view. For further information see the google maps API
specification:
http://code.google.com/intl/en-US/apis/maps/documentation/javascript/reference.html#MapOptions
{String}
type
The type of this object.
{Number}
zoomLevel
This property specifies the zoom level for this map view. It is directly
mapped to the zoom property of a google map view. For further information
see the google maps API specification:
http://code.google.com/intl/de-DE/apis/maps/documentation/javascript/reference.html#MapOptions
Method Detail
addMarker(marker)
This method can be used to add a marker to the map view. Simply pass a
valid M.MapMarkerView object and a map marker is created automatically,
displayed on the map and added to this map view's markers property.
- Parameters:
- {M.MapMarkerView} marker
- The marker to be added.
initMap(options, isUpdate)
This method is used to initialize a map view, typically out of a controller.
With its options parameter you can set or update almost every parameter of
a map view. This allows you to define a map view within your view, but then
update its parameters later when you want this view to display a map.
The options parameter must be passed as a simple object, containing all of
the M.MapView's properties you want to be updated. Such an options object
could look like the following:
{
zoomLevel: 12,
mapType: M.MAP_HYBRID,
initialLocation: location
}
While all properties of the options parameter can be given as Number, String
or a constant value, the location must be a valid M.Location object.
Once the google api is initialized, the success callback specified with the
options parameter is called. If an error occurs (e.g. no network connection),
the error callback is called instead. They can be specified like the
following:
{
callbacks: {
success: {
target: this,
action: function() {
// success callback
}
},
error: {
target: this,
action: function() {
// error callback
}
}
}
}
- Parameters:
- {Object} options
- The options for the map view.
- {Boolean} isUpdate
- Indicates whether this is an update call or not.
registerEvents()
This method is responsible for registering events for view elements and its child views. It
basically passes the view's event-property to M.EventDispatcher to bind the appropriate
events.
We use this to disable event registration for M.MapView, since we only use the 'events' property
for determining the handler for possible map markers of this map.
removeAllMarkers()
This method removes all markers from this map view. It both cleans up the
markers array and deletes the marker's visual representation from the map
view.
removeMarker(marker)
This method can be used to remove a certain marker from the map view. In
order to do this, you need to pass the M.MapMarkerView object that you
want to be removed from the map view.
- Parameters:
- {M.MapMarkerView} marker
- The marker to be removed.
renderUpdate()
This method is called if the bound content changed. This content must be
an array of M.Location objects or M.MapMarkerView objects. This method
will take care of a re-rendering of the map view and all of its bound
markers.
If M.Location objects are passed, the default settings for map markers
of this map view are assigned.
Note that you can not use individual click events for your markers if
you pass M.Location objects.
updateMap(options)
This method is used to update a map view, typically out of a controller.
With its options parameter you can update or update almost every parameter
of a map view. This allows you to define a map view within your view, but
then update its parameters later when you want this view to display a map
and to update those options over and over again for this map.
The options parameter must be passed as a simple object, containing all of
the M.MapView's properties you want to be updated. Such an options object
could look like the following:
{
zoomLevel: 12,
mapType: M.MAP_HYBRID,
initialLocation: location
}
While all properties of the options parameter can be given as Number, String
or a constant value, the location must be a valid M.Location object.
- Parameters:
- {Object} options
- The options for the map view.