Table Of Contents

Previous topic

gxp.plugins.LoadingIndicator

Next topic

gxp.plugins.MapQuestSource

gxp.plugins.MapBoxSource

Extends
ptype
gxp_mapboxsource
class gxp.plugins.MapBoxSource(config)

Plugin for using MapBox layers with gxp.Viewer instances. Freely available for commercial and non-commercial use according to the MapBox terms of service: http://mapbox.com/tos

Available layer names:
  • blue-marble-topo-bathy-jan
  • blue-marble-topo-bathy-jul
  • blue-marble-topo-jan
  • blue-marble-topo-jul
  • control-room
  • geography-class
  • natural-earth-hypso
  • natural-earth-hypso-bathy
  • natural-earth-1
  • natural-earth-2
  • world-dark
  • world-light
  • world-print

Example Use

The configuration in the sources property of the gxp.Viewer is straightforward:

mapbox: {
    ptype: "gxp_mapboxsource"
}

A typical configuration for a layer from this source (in the layers array of the viewer’s map config option would look like this:

{
    source: "mapbox",
    name: "blue-marble-topo-bathy-jan"
}

Config Options

Configuration properties in addition to those listed for Ext.util.Observable.

title
String A descriptive title for this layer source (i18n).

Public Properties

Public properties in addition to those listed for Ext.util.Observable.

MapBoxSource.lazy
Boolean. true when the source is ready, but its store hasn’t been loaded yet (i.e. lazy source). Read-only.
MapBoxSource.store
GeoExt.data.LayerStore. Will contain records with name field values matching MapBox layer names.
MapBoxSource.title
String A descriptive title for this layer source.

Public Methods

Public methods in addition to those listed for Ext.util.Observable.

MapBoxSource.createLayerRecord()
Parameter:configObject The application config for this layer.
Returns:GeoExt.data.LayerRecord

Create a layer record given the config.

MapBoxSource.createStore()
Creates a store of layer records. Fires “ready” when store is loaded.
MapBoxSource.getConfigForRecord()
Parameter:recordGeoExt.data.LayerRecord
Returns:Object

Create a config object that can be used to recreate the given record.

MapBoxSource.getProjection()
Parameter:layerRecordGeoExt.data.LayerRecord a record from this source’s store
Returns:OpenLayers.Projection A suitable projection for the layerRecord. If the layer is available in the map projection, the map projection will be returned. Otherwise an equal projection, or null if none is available.

Get the projection that the source will use for the layer created in createLayerRecord. If the layer is not available in a projection that fits the map projection, null will be returned.

MapBoxSource.getState()
Returns:Object

Gets the configured source state.

MapBoxSource.init()
Parameter:targetObject The object initializing this plugin.

Calls createStore() with a callback that fires the ‘ready’ event.

Events

Events in addition to those listed for Ext.util.Observable.

failure
Fires if the layer source fails to load.
ready
Fires when the layer source is ready for action.