Mapwize's API gives you the possibility to automatically push modifications to Mapwize objects like places, place lists, floorplan sources, connectors, ...
Using PUT requests, you can specify the properties of the object that need to change with their new values. For example, if you send
PUT /v1/places/{{placeId}}
with the request body
{
"name" : "My Modified Name",
"style" : {
"fillColor":"#ff0000",
"fillOpacity":1
}
}
the place with id {{placeId}} will be given a new name and a new style. All other properties of the object will not be modified.
Since style is a sub-object, it is completely replaces by the new object provided.
Now, what if you want to only modify the fillColor without touching the rest of the style object?
This is where the $set operator becomes handy. The $set operator lets you specify properties, possibly deep inside the object, that will be modified without touching the sub-objects, exactly like in mongoDB. The $set should be given an object with key / values. The keys support the . notation for going inside objects and the [ ] notation to go inside arrays.
To take an example:
PUT /v1/places/{{placeId}}
with the request body
{
"name" : "My Modified Name",
"$set" : {
"style.fillColor":"#ff0000",
"style.fillOpacity":1,
"data.myarray[2].myproperty.a.b.c":"X"
}
}
In the data that can contain a freely defined JSON, if the hierarchy to set the value is not defined, it will be created.
The $set operator is available for
- venues
- places
- placeTypes
- placeLists
- connectors
- layers
- sources
- beacons
Comments
0 comments
Please sign in to leave a comment.