Sources
setSource
map.setSource(id, geoJson, cluster, maxZoom, radius)
Parameters
id
The ID of the source to add. Must not conflict with existing sources.
String
geoJson
A source containing GeoJSON.
Object
cluster
Cluster enabled or disabled
Boolean
maxZoom
Max zoom to cluster points on (defaults to 14)
Numeric
radius
Radius of each cluster when clustering points
Int
Returns
Example
map.setSource('some id', {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [ 126.896038, 37.482901]ty
}
}]
},
//If you want to use the cluster
true, //cluster
15, // maxZoom to cluster
50 // radius
);
getSource
map.getSource(id)
Parameters
id
The ID of the source to get.
String
Returns
style source
The style source with the specified ID or undefined if the ID corresponds to no existing sources.
Object
Example
const srcStyle = map.getSource('some id');
setData
map.getSource('some id').setData(data);
Parameters
data
A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files.
Object | string
Returns
Example
map.getSource('some id').setData({
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [ 126.896038, 37.482901]
}
}]
});
isSourceLoaded
map.isSourceLoaded('some id');
Parameters
id
The ID of the source to be checked.
String
Returns
value
A Boolean indicating whether the source is loaded.
Boolean
Example
const isSrcloaded = map.isSourceLoaded('some id');
removeSource
map.removeSource('some id');
Parameters
id
The ID of the source to remove.
String
Returns
Returns itself to allow for method chaining.
Example
map.removeSource('some id');
The MOGOS Maps API requires an API Key, which can be obtained from the MOGOS Console website or contact [email protected].
Last updated