MOGOS Maps
console
  • Overview
  • API & COMPONENT
    • Maps
      • Map Control
        • Sources
        • Bounds
        • Zoom
        • Center
        • Rotate
        • Tilt
        • Flyto
        • Solid
        • Languages
        • Theme
        • Event Once
        • Event On/Off
      • Layer Control
        • Layers
        • Filters
        • Property
        • The specifation of layer style
          • Fill
          • Line
          • Circle
          • Symbol
      • Map UI
      • Map Utilities
        • Rectangle
        • Circle
        • Polyline
        • Polylgon
        • Area
        • Distance
        • Marker
          • Members
    • Search
      • Name
      • Category
      • Address
      • Postal Code
      • Geocoding
    • Route
      • General Vehicles
      • Motorbike
      • Bicycle
      • Pedestrian
      • Truck
      • Public Transportation
    • Logistics & Delivery
      • Route including multiple waypoints
      • Route as optimized order for multiple waypoints
      • Route as optimized order for transportation of logistics
      • Route as optimized order for delivery
      • Predicted route which is certain time in the future
    • Fleet Management
      • Realtime location tracking
      • Moving trajectory analysis
      • Driving road pattern analysis
      • Driver behavior analysis
      • Geofencing
      • Road snap
  • Help
    • Get your API Key
    • Troubleshooting
  • The last versions
    • MOGOS Maps API
      • MOGOS Maps API V1.0
Powered by GitBook

©MOGOS 2023

On this page
  • setSource
  • getSource
  • setData
  • isSourceLoaded
  • removeSource
  1. API & COMPONENT
  2. Maps
  3. Map Control

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');

PreviousMap ControlNextBounds

Last updated 2 years ago

The MOGOS Maps API requires an API Key, which can be obtained from the website or contact .

MOGOS Console
sales@mogoscorp.com