--- layout: api title: "v1.6.0 API: L.mapbox.markerLayer(id|url|tilejson, options)" categories: api version: v1.6.0 permalink: /api/v1.6.0/l-mapbox-markerlayer --- {% raw %}
L.mapbox.markerLayer
provides an easy way to integrate GeoJSON
from Mapbox and elsewhere into your map.
Options | Value | Description |
---|---|---|
id or url or tilejson | string if id or url object if tilejson | Must be either
|
options | object | If provided, it is the same options as provided to http://leafletjs.com/reference.html#featuregroup, as well as:
|
Example:
var markerLayer = L.mapbox.markerLayer(geojson)
.addTo(map);
Returns a L.mapbox.markerLayer
object.
Load GeoJSON data for this layer from the URL given by url
.
Options | Value | Description |
---|---|---|
url | string | A map id |
Example:
var markerLayer = L.mapbox.markerLayer()
.addTo(map);
markerLayer.loadURL('my_local_markers.geojson');
Returns: the layer object
Load marker GeoJSON data from a map with the given id
on Mapbox.
Options | Value | Description |
---|---|---|
url (required) | string | A map id |
Example:
var markerLayer = L.mapbox.markerLayer()
.addTo(map);
// loads markers from the map `examples.map-0l53fhk2` on Mapbox,
// if that map has markers
markerLayer.loadID('examples.map-0l53fhk2');
Returns: the layer object
Sets the filter function for this data layer.
Options | Value | Description |
---|---|---|
filter (required) | function | a function that takes GeoJSON features and returns true to show and false to hide features. |
Example:
var markerLayer = L.mapbox.markerLayer(geojson)
// hide all markers
.setFilter(function() { return false; })
.addTo(map);
Returns the markerLayer object.
Gets the filter function for this data layer.
Example:
var markerLayer = L.mapbox.markerLayer(geojson)
// hide all markers
.setFilter(function() { return false; })
.addTo(map);
// get the filter function
var fn = markerLayer.getFilter()
Returns the filter function.
Set the contents of a markers layer: run the provided features through the filter function and then through the factory function to create elements for the map. If the layer already has features, they are replaced with the new features. An empty array will clear the layer of all features.
Options | Value | Description |
---|---|---|
geojson (required) | object | features , an array of GeoJSON feature objects, or omitted to get the current value. |
Example:
var markerLayer = L.mapbox.markerLayer(geojson)
.addTo(map);
// a simple GeoJSON featureset with a single point
// with no properties
markerLayer.setGeoJSON({
type: "FeatureCollection",
features: [{
type: "Feature",
geometry: {
type: "Point",
coordinates: [102.0, 0.5]
},
properties: { }
}]
});
Returns the markerLayer object
Get the contents of this layer as GeoJSON data.
Returns the GeoJSON represented by this layer
{% endraw %}