MapSVG has 2 data sets (called repositories): map.objectsRepository
and map.regionsRepository
.
map.objectsRepository
contains what you create in the "Databas" tab in MapSVG control panel.
map.regionsRepository
contains what you create in the "Regions" tab in MapSVG control panel.
Both of the repositories have the same structure and the same methods.
CRUD
Get
When you need to get on or more of the created maps instances, you can do so via MapSVG
global variable.
Get map by index (in the order of creation):
const allObjects = map.objectsRepository.getLoaded()
const allRegions = map.regionsRepository.getLoaded()
const object = map.objectsRepository.findById(OBJECT_ID)
const region = map.regionsRepository.findById(OBJECT_ID)
Search:
const filteredObjects = map.objectsRepository.find({filters: {category: 1}})
const filteredRegions = map.regionsRepository.find({filters: {category: 1}})
You can call the method above outside of the map. When you call it, MapSVG makes a request to the server, gets the results and reloads markers on the map and directory items, and changes selected filters fields.
Create / Update / Delete
You can't modify objects using JavaScript API - you can do that only in MapSVG cotrol panel.