Marker
Summary
A marked location on a map.
A Marker is a type of ViewModel, which means that it can bind its attributes to a data model (Model or Backbone.Model). This allows you to easily bind data from an API to a marker, or MarkerCollection.
For example, say you have a data model called Place
, which receives data from an API like so:
var place = new Place();
place.fetch();
//...
place.toJSON === {
id: 1,
description: 'Joe\'s bar and grill.',
category: 'restaurant',
location: {
lat: 45.23,
long: -90.87
}
}
You can now bind a Marker to the place data:
var placeMarker = new aeris.maps.Marker(null, {
data: place,
// Use attribute transforms to translate raw data
// into marker attributes.
// Any changes to the Place model will be reflected
// in the placeMarker, using these attributeTransforms.
attributeTransforms: {
// Format position as [lat, lon]
position: function() {
return [
this.getDataAttribute('location.lat'),
this.getDataAttribute('location.long')
];
},
// Use data description as marker title
title: function() {
return this.getDataAttribute('description');
},
// Choose a icon url based on the
// data category
url: function() {
var category = this.getDataAttribute('category');
if (category === 'restaurant') {
return 'restaurant_icon.png';
}
else {
return 'some_other_place_icon.png'
}
}
}
});
Constructor
aeris.maps.markers.Marker
Syntax
aeris.maps.markers.Marker
-
opt_attrs
-
opt_options
Summary
Parameters:
-
opt_attrs
Object=-
position
LatLonThe lat/lon position to set the Marker.
-
clickable
Boolean=Whether the user can click the marker. Default is true.
-
draggable
Boolean=Whether the user can drag the marker. Default is true.
-
url
String=URL to the icon.
-
width
Number=Width of the icon, in pixels.
-
height
Number=Height of the icon, in pixels.
-
-
opt_options
Object=-
strategy
AbstractStrategy
-
Item Index
Methods
Properties
Events
Methods
createStrategy_
Syntax
Summary
Create a {aeris.maps.AbstractStrategy} instance.
Override to adjust how strategy objects are instantiated.
Parameters:
-
Strategy
FunctionAbstractStrategy object ctor.
Returns:
destroy
Syntax
destroy
()
Summary
getMap
Syntax
getMap
()
Summary
getType
Syntax
Summary
This method method may be overriden to return an arbitrary "type" category for the marker. Used by MarkerClusterer strategies to split up a single MarkerColection into several cluster sets.
Returns:
removeStrategy
Syntax
removeStrategy
()
Summary
Remove and clean up the StrategyObject's strategy.
resetStrategy
Syntax
resetStrategy
()
Summary
Reset the rendering strategy used by the object. Useful for re-enabled a strategy which has previously been removed with StrategyObject#removeStrategy
setMap
Syntax
setMap
()
Summary
setStrategy
Syntax
setStrategy
-
Strategy
Summary
Set the strategy to use for rendering the StrategyObject.
Parameters:
-
Strategy
FunctionConstructor for an {aeris.maps.AbstractStrategy} object.
validate
Syntax
validate
()
protected
Summary
Properties
strategy_
Syntax
strategy_
aeris.maps.Strategy Strategy constructor.
Summary
Default {aeris.Strategy} implementation
StrategyType_
Syntax
StrategyType_
function():aeris.maps.AbstractStrategy
private
Summary
Attributes
Events
dragend
Syntax
dragend
Summary
Event Payload:
-
latLon
aeris.maps.LatLon -
marker
aeris.maps.markers.Marker
strategy:set
Syntax
strategy:set
Summary
When a strategy is set on the object.
Event Payload:
-
strategy
aeris.maps.AbstractStrategy