Closed andersonreloaded closed 7 years ago
Hello,
After adding plots, you can update them using the update
trigger.
The following examples may interest you:
To answer your question, you don't have to list all the plots if you need to update only a few.
For instance, you can simply do this to update the plot color named rennes
:
$(".mapcontainer").trigger('update', [{
mapOptions: {
plots: {
"rennes": {
attrs: {
fill: "red"
}
}
}
}
}]);
Hope it helps.
Not related, but why are you still using Firefox 29? I believe Firefox 31 was the ESR version. Also, it seems no longer supported by Mozilla since 2014...
Just curious :)
Hi,
Thank you for your response.
I am working on the same lines as mentioned in the example, however instead of listing the plots is it possible to just set the property like plots["name"].attrs.fill = "red". I am not a hardcore programmer, so my questions may sound silly. Secondly, how do I build the list of plots from XML/JSON data responded by the server. Where is the plots data stored at the client side. It would be simple to access and set the property.
I expected this curious question on Firefox version :-). System is not connected to Internet, so the older versions continue to see the day!
Regards.
Of course you can. Just create the object first and assign new values to it.
// Create plots object that will be used in `update` trigger
var updatedPlots = {};
// Create an empty plot object
updatedPlots['rennes'] = {};
// Create an empty attribute object
updatedPlots['rennes'].attrs = {};
// Assign any attributes you need
updatedPlots["rennes"].attrs.fill = "red";
// Use updatedPlots to update the relevent plots
$(".mapcontainer").trigger('update', [{
mapOptions: {
plots: updatedPlots
}
}]);
Regarding JSON import, this example may help you: Importing data from JSON
Thank you. I understood that we need to build the plots with updated properties and trigger an update with the new set of plots objects.
But, just curious to know where the plot objects are stored at the client side by jQuery Mapael library.
Regards!
Internally, the plots are stored in plots
object. You can see it with:
// Retrieve Mapael object
var mapael = $('.mapcontainer').data('mapael');
// See internals...
console.log(mapael.plots);
However, it is not recommended to update directly the internal objects: your code may break with any Mapael update as internal modification may change without notice.
Thank you!
Hi Folks,
After drilling down various packages found jQuery Mapael to be simple and easy to use. Thanks for nice set of examples provided.
Description
Based on a timer event, client shall fetch JSON or XML data of various plots. The same need to be updated on the map. For example, I have been using vis.js for display of network topology and health of each network element is updated by pulling the summary from the server. The node properties can be updated dynamically. Would like to know if similar approach is available for updating the plot status.
Expected Behavior
Wish to dynamically update status/health of plots shown on the map. Is there a way to access the 'plots' object and update the settings such as color or image ?.
Current Behavior
I believe that currently the list of complete 'plots' need to be prepared and updated on the map.
Environment