OpenLayers.Layer.Text

This layer creates markers given data in a text file.  The location property of the layer (specified as a property of the options argument in the OpenLayers.Layer.Text constructor) points to a tab delimited file with data used to create markers.

The first row of the data file should be a header line with the column names of the data.  Each column should be delimited by a tab space.  The possible columns are:

  • point lat,lon of the point where a marker is to be placed
  • lat Latitude of the point where a marker is to be placed
  • lon Longitude of the point where a marker is to be placed
  • icon or image URL of marker icon to use.
  • iconSize Size of Icon to use.
  • iconOffset Where the top-left corner of the icon is to be placed relative to the latitude and longitude of the point.
  • title The text of the ‘title’ is placed inside an ‘h2’ marker inside a popup, which opens when the marker is clicked.
  • description The text of the ‘description’ is placed below the h2 in the popup. this can be plain text or HTML.

Example text file

lat  lon title   description iconSize    iconOffset  icon
10   20  title   description 21,25       -10,-25     http://www.openlayers.org/dev/img/marker.png

Inherits from

Summary
OpenLayers.Layer.TextThis layer creates markers given data in a text file.
Properties
location{String} URL of text file.
features{Array(OpenLayers.Feature)}
formatOptions{Object} Hash of options which should be passed to the format when it is created.
selectedFeature{OpenLayers.Feature}
Constructor
OpenLayers.Layer.TextCreate a text layer.
Functions and Properties
destroy
loadTextStart the load of the Text data.
moveToIf layer is visible and Text has not been loaded, load Text.
parseData
markerClick
clearFeatures

Properties

location

{String} URL of text file.  Must be specified in the “options” argument of the constructor.  Can not be changed once passed in.

features

formatOptions

{Object} Hash of options which should be passed to the format when it is created.  Must be passed in the constructor.

selectedFeature

Constructor

OpenLayers.Layer.Text

Create a text layer.

Parameters

name{String}
options{Object} Object with properties to be set on the layer.  Must include location property.

Functions and Properties

destroy

destroy: function()

loadText

loadText: function()

Start the load of the Text data.  Don’t do this when we first add the layer, since we may not be visible at any point, and it would therefore be a waste.

moveTo

moveTo:function(bounds,
zoomChanged,
minor)

If layer is visible and Text has not been loaded, load Text.

Parameters

bounds{Object}
zoomChanged{Object}
minor{Object}

parseData

parseData: function(ajaxRequest)

Parameters

ajaxRequest{OpenLayers.Request.XMLHttpRequest}

markerClick

Parameters

evt{Event}

Context

clearFeatures

clearFeatures: function()
Features are combinations of geography and attributes.
destroy: function()
loadText: function()
Start the load of the Text data.
moveTo:function(bounds,
zoomChanged,
minor)
If layer is visible and Text has not been loaded, load Text.
parseData: function(ajaxRequest)
clearFeatures: function()
{String} URL of text file.
Create a text layer.
Standard-compliant (W3C) cross-browser implementation of the XMLHttpRequest object.
Close