Fork me on GitHub

Classes

lvector.AGS ArcGIS Server

This class creates a layer that processes and displays features from an ArcGIS Server. You can also use this class to create a layer from any services that implement Esri's Geo REST specification, like Arc2Earth.

Usage Example

var myAGSLayer = new lvector.AGS({
    url: "http://maps.rtd-denver.com/ArcGIS/rest/services/BusLocations/MapServer/0",
    fields: "*",
    uniqueField: "OBJECTID",
    scaleRange: [13, 20],
    popupTemplate: "<h3>Bus #{BUS_NUMBER}</h3><p>Speed: {SPEED} mph</p>"                
});

Constructor

ConstructorDescription
lvector.AGS( <AGS options> options )Instantiates an AGS layer with an object literal with AGS options described below.

Options

OptionTypeDefault ValueDescription
urlStringnullRequired - A url for a specific layer in an ArcGIS Server service.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or after a defined interval. For details check the dynamic data documentation.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated at an interval set by the autoUpdateInterval option. For details check the dynamic data documentation.
autoUpdateIntervalIntegernullThe interval (in milliseconds) between checks for updated feature geometry and attributes when the autoUpdate option is set to true. For details check the dynamic data documentation.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.
fieldsStringnullA list of comma separated fields to be returned with the features. For example "OBJECTID,OWNER_NAME" returns two fields and "*" returns all fields.
uniqueFieldStringnullA field in the returned data that can be considered unique. This isn't required but is very helpful in determining which features are already on the map when the map extent changes.
clickEventFunctionnullA user defined click event. For details check the Custom clickEvent options documentation.

Methods

MethodDescription
setMap( <L.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

lvector.A2E Arc2Earth

This class creates a layer that processes and displays features from an Arc2Earth Sync instance.

Usage Example

var myA2ELayer = new lvector.A2E({
    url: "http://sync.arc2earth.com/6442491/ArcGIS/rest/services/tfs/2447544/FeatureServer/0",
    esriOptions: true,
    uniqueField: "global_fid",
    popupTemplate: '<div class="iw-content"><h3>{Name}</h3></div>',
    singlePopup: true,
    dynamic: true,
    autoUpdate: true
});

Constructor

ConstructorDescription
lvector.A2E( <A2E options> options )Instantiates an A2E layer with an object literal with A2E options described below.

Options

OptionTypeDefault ValueDescription
urlStringnullRequired - A url for a specific layer in an ArcGIS Server service.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or when a PubNub message is sent to the client.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated in near real-time by subscribing to PubNub events.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.
fieldsStringnullA list of comma separated fields to be returned with the features. For example "OBJECTID,OWNER_NAME" returns two fields and "*" returns all fields.
uniqueFieldStringnullA field in the returned data that can be considered unique. This isn't required but is very helpful in determining which features are already on the map when the map extent changes.
esriOptionsBooleanfalseWhether or not to request scaleRange and symbology settings from the Arc2Earth Sync back-end. Layers loaded from ArcGIS Desktop into Arc2Earth Sync will retain scaleRange and symbology settings from ArcGIS Desktop.
clickEventFunctionnullA user defined click event. For details check the Custom clickEvent options documentation.

Methods

MethodDescription
setMap( <L.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

lvector.GeoIQ GeoIQ - Geocommons

This class creates a layer that processes and displays features from a GeoIQ dataset.

Usage Example

var myGeoIQLayer = new lvector.GeoIQ({
    dataset: 164880,
    uniqueField: "NAME",
    scaleRange: [6, 20],
    popupTemplate: '<div class="iw-content"><h3>{NAME}</h3></div>',
    singlePopup: true,
    symbology: {
        type: "single",
        vectorOptions: {
    	    icon: new customIcon({
                iconUrl: "../../docs-demo/img/markers/ski-lift.png"
            })
        }
    }
});

Constructor

ConstructorDescription
lvector.GeoIQ( <GeoIQ options> options )Instantiates a GeoIQ layer with an object literal with GeoIQ options described below.

Options

OptionTypeDefault ValueDescription
datasetNumbernullRequired - A dataset id for a GeoIQ/Geocommons dataset.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or after a defined interval. For details check the dynamic data documentation.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated at an interval set by the autoUpdateInterval option. For details check the dynamic data documentation.
autoUpdateIntervalIntegernullThe interval (in milliseconds) between checks for updated feature geometry and attributes when the autoUpdate option is set to true. For details check the dynamic data documentation.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.
uniqueFieldStringnullA field in the returned data that can be considered unique. This isn't required but is very helpful in determining which features are already on the map when the map extent changes.
clickEventFunctionnullA user defined click event. For details check the Custom clickEvent options documentation.

Methods

MethodDescription
setMap( <L.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

lvector.CartoDB CartoDB

This class creates a layer that processes and displays features from a CartoDB table.

Usage Example

var myCartoDBLayer = new lvector.CartoDB({
    user: "geojason",
    table: "man_hole",
    scaleRange: [16, 20],
    symbology: {
        type: "single",
        vectorOptions: {
            icon: new customIcon({
                iconUrl: "../../docs-demo/img/markers/manhole.png"
            })
        }
    },
    popupTemplate: '<h3>Man Hole</h3<p>Depth: {mh_depth}</p>',
    singlePopup: true
});

Constructor

ConstructorDescription
lvector.CartoDB( <CartoDB options> options )Instantiates a CartoDB layer with an object literal with CartoDB options described below.

Options

OptionTypeDefault ValueDescription
userStringnullRequired - The CartoDB user that owns the table to be displayed. For example a CartoDB map viewed via a URL like http://geojason.cartodb.com/map, "geojason" is the CartoDB user.
tableStringnullRequired - The CartoDB table name for the data to be displayed.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or after a defined interval. For details check the dynamic data documentation.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated at an interval set by the autoUpdateInterval option. For details check the dynamic data documentation.
autoUpdateIntervalIntegernullThe interval (in milliseconds) between checks for updated feature geometry and attributes when the autoUpdate option is set to true. For details check the dynamic data documentation.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.
fieldsString"*"A list of comma separated fields to be returned with the features. By default all fields are returned.
clickEventFunctionnullA user defined click event. For details check the Custom clickEvent options documentation.

Methods

MethodDescription
setMap( <L.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

lvector.PRWSF PostGIS RESTful Web Service Framework

This class creates a layer that processes and displays features from a PostGIS RESTful Web Service Framework geotable.

The PostGIS RESTful Web Service Framework is an open source project written in PHP that creates a set of web services that allow you to query geo data in a PostGIS database. These web services are extemely flexible allowing you to project, aggregate, order and serialize your data in many different ways. Below are some implementations I've found:

Usage Example

var myPrwsfLayer = new lvector.PRWSF({
    url: "http://gis.drcog.org/REST",
    geotable: "mountain_backdrop_preservation_area",
    fields: "gid",
    uniqueField: "gid",
    geomPrecision: 6,
    srid: 2232,
    showAll: true,
    symbology: {
        type: "single",
        vectorOptions: {
            fillColor: "#2f4a00",
            fillOpacity: 0.4,
            strokeWeight: 1.8,
            strokeColor: "#2f4a00",
            strokeOpacity: 1,
            clickable: false
        }
    }
});

Constructor

ConstructorDescription
lvector.PRWSF( <PRWSF options> options )Instantiates a PRWSF layer with an object literal with PRWSF options described below.

Options

OptionTypeDefault ValueDescription
urlStringnullRequired - The root URL for the PostGIS RESTful Web Service Framework instance.
geotableStringnullRequired - The geotable for which we want data to be displayed.
fieldsStringnullA list of comma separated fields to be returned with the features. By default only the geometry field is returned. You'd likely want to also return a unique id and some other attribute information.
geomFieldNameString"the_geom"The geometry field name for this geotable. Most commonly found as the_geom
geomPrecisionIntegernullUsed to reduce the maximum number of decimal places in the PostGIS ST_AsGeoJSON output (PostGIS defaults to 15).
sridIntegernullThe SRID of the geometry in this geotable. This isn't required but increases performance drastically as the bounding box geometry can be projected to match your features' projection, which makes use of spatial indexes (that you've hopefully built).
whereStringnullAny additional SQL query(ies) to further filter the returned features.
limitIntegernullLimit the number of returned features.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or after a defined interval. For details check the dynamic data documentation.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated at an interval set by the autoUpdateInterval option. For details check the dynamic data documentation.
autoUpdateIntervalIntegernullThe interval (in milliseconds) between checks for updated feature geometry and attributes when the autoUpdate option is set to true. For details check the dynamic data documentation.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.
clickEventFunctionnullA user defined click event. For details check the Custom clickEvent options documentation.

Methods

MethodDescription
setMap( <L.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

lvector.GISCloud GIS Cloud

This class creates a layer that processes and displays features from a GIS Cloud map layer.

Usage Example

var myGisCloudLayer = new lvector.GISCloud({
    mapID: 27322,
    layerID: 117755,
    symbology: {
        type: "single",
        vectorOptions: {
            weight: 4,
            color: "#46461f",
            opacity: 0.8
        }
    },
    scaleRange: [13, 18]
});

Constructor

ConstructorDescription
lvector.GISCloud( <GISCloud options> options )Instantiates a GISCloud layer with an object literal with GISCloud options described below.

Options

OptionTypeDefault ValueDescription
mapIDString|NumbernullRequired - The GIS Cloud Map ID where your layer can be found.
layerIDString|NumbernullRequired - The GIS Cloud Layer ID for your layer.
whereStringnullAny additional SQL query(ies) to further filter the returned features.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or after a defined interval. For details check the dynamic data documentation.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated at an interval set by the autoUpdateInterval option. For details check the dynamic data documentation.
autoUpdateIntervalIntegernullThe interval (in milliseconds) between checks for updated feature geometry and attributes when the autoUpdate option is set to true. For details check the dynamic data documentation.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.
clickEventFunctionnullA user defined click event. For details check the Custom clickEvent options documentation.

Methods

MethodDescription
setMap( <google.maps.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

lvector.GitSpatial GitSpatial

This class creates a layer that processes and displays features from a GitSpatial feature set.

Usage Example

my_gitspatial_layer = new lvector.GitSpatial({
    user: 'JasonSanford',
    repo: 'mecklenburg-gis-opendata',
    feature_set: 'parks',
    popupTemplate: '<div class="iw-content"><h3>{name}</h3>Address: {address}</div>'
});

Constructor

ConstructorDescription
lvector.GitSpatial( <GitSpatial options> options )Instantiates a GitSpatial layer with an object literal with GitSpatial options described below.

Options

OptionTypeDefault ValueDescription
userStringnullRequired - The GitHub user id for a GitSpatial feature set.
repoStringnullRequired - The GitHub repo name for a GitSpatial feature set.
featureSetStringnullRequired - The GitSpatial feature set name.
mapObject L.Map objectnullThe Leaflet Map object where the layer will be added. The layer can be added to the map later with the setMap method.
scaleRangeArraynullAn array with two number values that represent the minimum and maximum scales the layer is visible. For example: [14, 17]
dynamicBooleanfalseWhether or not the layer contains dynamic data. If true, feature geometry and attributes will be checked for changes after extent change and/or after a defined interval. For details check the dynamic data documentation.
autoUpdateBooleanfalseWhether or not to auto-update a dynamic layer. If true, feature geometry and attributes will be updated at an interval set by the autoUpdateInterval option. For details check the dynamic data documentation.
autoUpdateIntervalIntegernullThe interval (in milliseconds) between checks for updated feature geometry and attributes when the autoUpdate option is set to true. For details check the dynamic data documentation.
popupTemplateString|FunctionnullA template for creating the content of a Leaflet Popup when a feature is clicked. For details check the Popup Template documentation.
singlePopupBooleanfalseWhether or not to show a single Popup for a layer when features are clicked. This keeps the map from getting cluttered when multiple features are clicked.
popupOptionsObject Leaflet Popup optionsnullControls the width of and the presence of a close button for the Popup and whether the map should be panned when the Popup is opened.
symbologyObject symbology optionsnullThe symbology options for the layer. Features can be rendered with a single symbology or can also be symbolized based on an attribute using unique values or a value range. For details check the symbology options documentation.
showAllBooleanfalseIf true, all features will be fetched and shown once, not after a map extent change. This is helpful for layers with only a handful of features.

Methods

MethodDescription
setMap( <google.maps.Map> Map )Adds the layer to a map. Remove the layer by passing null.
getMap()Gets the map (if any) that the layer has been added to.

Other Reference

Symbology

Symbology for a layer can be defined a few different ways including single, unique and range. If no symbology is defined the default Leaflet vector styles will be used.

When instantiating a new layer, use one of the options below when setting the symbology option value.

Note that marker icons may also have a title option for defining a tooltip on mouseover.

single

The single type displays all features with the same symbology.

{
    type: "single", // Defines the symbology as a single type of representation for all features
    vectorOptions: { // Leaflet Path options for all features
        fillColor: "#46461f",
        fillOpacity: 0.5,
        weight: 4,
        color: "#ff7800"
    }    
}

unique

The unique type displays features with the same attibute values with the same symbology. This is helpful when you have a handful of discrete values for which you want to define symbology.

Check the districts example on the ArcGIS Server demo page and view source to see it in action.

{
    type: "unique", // Defines the symbology as a unique type where features with an attribute of a specific value are symbolized the same way
    property: "DISTRICT", // The property (field, attribute) to use for defining unique values and styles
    values: [ // An array of values to set symbology. Each value has a specific symbology
        {
            value: "A", // If feature.properties.DISTRICT == "A"
            vectorOptions: { // Use these Leaflet Path options for features matching
                fillColor: "#6600FF",
                fillOpacity: 0.6,
                color: "#666666",
                opacity: 0.8,
                weight: 1
            }
        },
        {
            value: "B",
            vectorOptions: {
                fillColor: "#660066",
                fillOpacity: 0.6,
                color: "#666666",
                opacity: 0.8,
                weight: 1
            }
        },
        {
            value: "C",
            vectorOptions: {
                fillColor: "#FF9900",
                fillOpacity: 0.6,
                color: "#666666",
                opacity: 0.8,
                weight: 1
            }
        }
    ]
}

range

The range type tests values to see if they are within a specified range and symbolizes them accordingly. This is helpful for datasets that have values with lots of individual values like population counts per county in the US or in this example, vehicle speeds.

{
    type: "range", // Defines the symbology as a range type where values above a minimum and below a maximum value are symbolized the same way
    property: "SPEED", // The property (field, attribute) to use for defining range values and styles
    ranges: [ // An array of value ranges to set symbology. Each value range has a specific symbology.
        {
            range: [1, 20], // if feature.properties.SPEED >= 1 AND feature.properties.SPEED <= 20
            vectorOptions: { // Use these Leaflet Path options for features with values in this range
                icon: new customIcon({
                    iconUrl: "../../docs-demo/img/markers/bus-brown.png"
                }),
                title: "{SPEED} mph"
            }
        },{
            range: [21, 100],
            vectorOptions: {
                icon: new customIcon({
                    iconUrl: "../../docs-demo/img/markers/bus-green.png"
                }),
                title: "{SPEED} mph"
            }
        }
    ]
}

Popup Templates

To create content to show Popups when features are clicked we can use the popupTemplate option. A popupTemplate can be set two ways:

String Based

A simple popupTemplate might look like:

"<h3>{road_name}</h3><p>Speed Limit: {speed_limit} mph</p>"

which gets transformed to:

"<h3>S Bemis St</h3><p>Speed Limit: 25 mph</p>"

Function Based

For more flexibility we can use a function to do some more complex operations with our feature properties for customized output. A function for a popupTemplate might look like:

function(properties) {
    /* Assuming "properties" is an object like:
    {
        ROAD_NAME: "S Bemis St",
        SPEED_LIMIT: 25
    }
    */
    
    var output = "<h3>State Road</h3>";
    
    for (var prop in properties) {
        output += prop.replace(/_/gi, " ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}) + ": " + properties[prop] + "<br />";
    }
    return output;
}

This function iterates through each property in properties and formats each to Proper Case for better looking output.

"<h3>State Road</h3>Road Name: S Bemis St<br />Speed Limit: 25<br />"

Custom clickEvent

In addition to opening popups, you may want to define your own click events. This is useful for appending data to a div or opening a modal dialog. To create a custom click event, we can use the clickEvent option and pass a function with feature and event arguments.

Example

The following example will pop up an alert box with the 'name' attribute when the marker is clicked:

prwsf_libraries = new lvector.PRWSF({
    url: "http://maps.co.mecklenburg.nc.us/rest",
    geotable: "libraries",
    fields: "gid,name,address,city",
    uniqueField: "gid",
    srid: 2264,
    scaleRange: [7, 20],
    showAll: true,
    symbology: {
        type: "single",
        vectorOptions: {
            icon: new customMarker()
        }
    },
    clickEvent: function (feature, event) {
        alert(feature.properties.name);
    }
});

Dynamic Data

To create a dynamic layer simply set the dynamic option to true. Using this option alone (without autoUpdate and autoUpdateInterval) will check for feature geometry and property changes when the map extent changes. If geometry changes are found the feature is altered on the map. If properties changes are found any Popups associated with this feature are updated to reflect this change.

Auto-update

Using the autoUpdate and autoUpdateInterval options we can set a layer to automatically fetch new features every x seconds, even when the map extent hasn't changed. Set the autoUpdate option to true and autoUpdateInterval to the amount of time (in milliseconds) for how often you want features fetched. To create a dynamic layer that auto-updates every 5 seconds you might create your layer like:

var myAGSLayer = new lvector.AGS({
    url: "http://maps.rtd-denver.com/ArcGIS/rest/services/BusLocations/MapServer/0",
    fields: "*",
    uniqueField: "OBJECTID",
    dynamic: true,
    autoUpdate: true,
    autoUpdateInterval: 5000
});

Arc2Earth

Auto-updating works slightly different with Arc2Earth layers. Since update messages are almost immediately sent to the client using PubNub, only the dynamic and autoUpdate parameters must be set (both to true). This eliminates the need for constant polling, thus reducing the load on the server.

An auto-updating Arc2Earth layer might look something like:

myA2ELayer = new lvector.A2E({
    url: "http://sync.arc2earth.com/6442491/ArcGIS/rest/services/tfs/2447544/FeatureServer/0",
    esriOptions: true,
    uniqueField: "global_fid",
    popupTemplate: '<div class="iw-content"><h3>{Name}</h3></div>',
    singlePopup: true,
    dynamic: true,
    autoUpdate: true
});