Sources

setSource

map.setSource(id, geoJson, cluster, maxZoom, radius)

Parameters

Parameter (Required)
Description
Remark

id

The ID of the source to add. Must not conflict with existing sources.

String

geoJson

A source containing GeoJSON.

Object

Parameter (Optional)
Description
Remark

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

Parameter
Description
Remark

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

Parameter (Required)
Description
Remark

id

The ID of the source to get.

String

Returns

Parameter
Description
Remark

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

Parameter (Required)
Description
Remark

data

A GeoJSON data object or a URL to one. The latter is preferable in the case of large GeoJSON files.

Object | string

Returns

Parameter
Description
Remark

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

Paraneter (Required)
Description
Remark

id

The ID of the source to be checked.

String

Returns

Return Value
Description
Remark

value

A Boolean indicating whether the source is loaded.

Boolean

Example

const isSrcloaded = map.isSourceLoaded('some id');

removeSource

map.removeSource('some id');

Parameters

Parameter (Required)
Description
Remark

id

The ID of the source to remove.

String

Returns

Parameter
Description
Remark

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