Fork me on GitHub
Show:

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 LatLon

      The 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=

Methods

createStrategy_

Syntax

createStrategy_

(
  • Strategy
)
AbstractStrategy protected

Summary

Create a {aeris.maps.AbstractStrategy} instance.

Override to adjust how strategy objects are instantiated.

Parameters:

  • Strategy Function

    AbstractStrategy object ctor.

Returns:

getPosition

Syntax

getPosition

() LatLon

Summary

Returns:

getSelectedUrl

Syntax

getSelectedUrl

() String

Summary

Returns:

getType

Syntax

getType

() ?string

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:

?string:

getUrl

Syntax

getUrl

() String

Summary

Return the url of the marker icon.

Returns:

getView

Syntax

getView

() *

Summary

Returns the object view, as rendered by the object's strategy.

Returns:

*:

hasMap

Syntax

hasMap

() Boolean

Summary

Returns:

Boolean:

Returns true if the layer has a map set.

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

setPosition

Syntax

setPosition

(
  • latLon
)

Summary

Parameters:

setSelectedUrl

Syntax

setSelectedUrl

(
  • selectedUrl
)

Summary

Parameters:

setStrategy

Syntax

setStrategy

(
  • Strategy
)

Summary

Set the strategy to use for rendering the StrategyObject.

Parameters:

  • Strategy Function

    Constructor for an {aeris.maps.AbstractStrategy} object.

setUrl

Syntax

setUrl

(
  • url
)

Summary

Parameters:

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

clickable

Boolean

Whether to allow click events on the marker.

draggable

Boolean

Whether to allow drag events on the marker.

map

Map protected

An AerisMap that the object is bound to. This is set with setMap.

offsetX

number

Pixels between the marker's lat/lon position and the left side of the icon image.

offsetY

number

Pixels between the marker's lat/lon position and the top of the icon image.

title

string

Marker title.

Default: ''

url

string

Icon url.

Events

click

Syntax

click

Summary

Event Payload:

dragend

Syntax

dragend

Summary

Event Payload:

strategy:set

Syntax

strategy:set

Summary

When a strategy is set on the object.

Event Payload: