Ignition has built-in Map Support for OpenStreetMap and Google Maps. I have configured the center position, but I don’t understand how add pins, shapes, and layers, any suggestion?
The required fields show up for the many properties when you add an array element to that property, which should be enough to get started. For example, if you go to props.layers.ui.marker and add an element for marker, it will go from this:
To this:
Our implementation of maps is from Leaflet, so if you want a deep dive explanation of all the properties, you can see the full documentation from Leaflet here Leaflet Docs. I would suggest that if you run into properties that don’t immediately make sense to check out their docs first.
Thank a lot, I read the documentation from Leaflet.
If I want to define markers from a query, I suppose that I must transform each row in the query result in a marker object with a specific shape (like in property editor), but how can I do it from script?
I’m trying with a transform script:
value_objects = []
py_value = system.dataset.toPyDataSet(value)
for row in py_value:
value_objects.append({'lat':row['latitude'], 'lng':row['longitude']})
return value_objects
In order to append directly to the marker array, you will have to define the rest of the required key/values and objects for the individual markers. Your script creates the lat and lng properties, but is missing other important parts. I’ve written a sample script that mimics the default marker object.
You probably can strip away some of the unused variables, but this will give you all the options we would normally start a new marker with and can be edited to fit better with your project.
I'm trying to customize icon, I uploaded image to the Image Management tool in a new folder and I'm using that in image component (source = "/system/images/newFolder/logo.png" and mode = fill)
How can I do the same thing with marker's icon ?
icon = {'path':'/system/images/newFolder/logo.png','size':{}} doesn't work, this is the error:
[Browser Events Thread] INFO Perspective.Designer.BrowserConsole - onerrorLogger: {"msg":"Uncaught Exception","errorMsg":"Script error.","url":"","line number":0,"column":0}
[Browser Events Thread] INFO Perspective.Designer.BrowserConsole - Uncaught Error: iconUrl not set in Icon options (see the docs).
Map marker icons currently don't work as we expect, so you will have to skip this part for now. When they get working though, they will be using the Icon paths we have defined, not the regular Image Management image paths you may be used to from Vision.
Ok, so I will have to create a svg file with the icons and I will have to copy this file in the gateway’s folder data\modules\com.inductiveautomation.perspective\icon
When locating component attributes, you must include the sub category that the property is in, for layers property in a map that is PROPS. So it would look like:
self.getSibling("Map").props.layers.ui.marker
It looks like the Perspective documentation for that is not correct in their examples, I'll let the documentation guys know.
I can view and manipulate. However, the append method doesn't seem to work. For example, I'm reading an array with a length of 2 (i.e. two markers) and when I try to appends like this (from the example above):
java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
However, if I start with an empty list I can append. The Map component appears to be using a PyArray however according to the documentation I've seen this should behave like the list's append method. I must be missing something.
About the marker Icons: I can change the marker icon and size, however seem to be unable to change the color.
As far as the color property goes, I've tried RGB, Hex integer and java.awt.Color values all seem to be ignored. I did notice that the Icon component has a color property that seems to be unicode.
This code worked for me.
Is there any way, a conditional statement can be run inside the 'for' loop?
Like changing the color of the marker according to the value of row['variable'].