# Map marker in perspective

**URL:** <https://forum.inductiveautomation.com/t/map-marker-in-perspective/90276>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 12, 2024, 7:02am UTC](https://forum.inductiveautomation.com/t/map-marker-in-perspective/90276 "2024-05-12T07:02:36Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 12, 2024, 8:10pm UTC](https://forum.inductiveautomation.com/t/map-marker-in-perspective/90276/8 "2024-05-12T20:10:30Z")

</div>

I've never used the Map component but was interested in your question. Try this:

![Map markers 1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/7/279be61b4650c4dcba19d1631ac958cfdf617bfa.png)

_Figure 1._

1. Create two custom properties on the Map component:

- **vehicleStatus** and create a binding on this to your GPS data tags that you posted above.
- **sampleMarker**. Create the property and paste in a sample marker or the one below.

> **sampleMarker**
>
> ```python
> {
> "name": "marker0",
> "properties": {},
> "enabled": true,
> "lat": 25.938225,
> "lng": 49.938877,
> "opacity": 1,
> "icon": {
> "path": "material/location_on",
> "color": "#4190F7",
> "rotate": 0,
> "size": {
> "width": 36,
> "height": 36
> },
> "style": {
> "classes": ""
> }
> },
> "event": {
> "stopPropagation": false
> },
> "tooltip": {
> "content": {
> "text": "Vehicle ID",
> "view": {
> "path": "",
> "params": {}
> }
> },
> "direction": "auto",
> "permanent": false,
> "sticky": false,
> "opacity": 1
> },
> "popup": {
> "enabled": false,
> "content": {
> "text": "",
> "view": {
> "path": "",
> "params": {}
> }
> },
> "width": {
> "max": 300,
> "min": 50
> },
> "height": {
> "max": null
> },
> "pan": {
> "auto": true
> },
> "closeButton": true,
> "autoClose": true,
> "closeOnEscapeKey": true,
> "closeOnClick": null
> }
> }
> 
> ```

1. Create a property binding on `ui.marker` as shown below.  
 ![Map markers 2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/1401c2b877408cf70fedf0c64e02dcc8b29d3aab.png)

_Figure 2._

1. Paste in the following code:

> **ui.marker binding script transform**
>
> ```python
> 
> def recursiveCopy(original):
> # With credit to https://forum.inductiveautomation.com/u/lrose
> # https://forum.inductiveautomation.com/t/copy-dictionary-and-modify-it-without-affecting-the-original/62297/9
> from copy import deepcopy
> from com.inductiveautomation.ignition.common.script.abc import AbstractMutableJythonMap,AbstractMutableJythonSequence
> 	
> if isinstance(original,AbstractMutableJythonMap):
> return {key:recursiveCopy(value) for key,value in original.iteritems()}
> 	
> if isinstance(original,AbstractMutableJythonSequence):
> return [recursiveCopy(item) for item in original]
> 	
> return deepcopy(original)
> 	
> markers = []
> for car in value['tags']:
> protoMarker = recursiveCopy(self.custom.sampleMarker)
> name = car['name']
> for dic in car['tags']:
> if dic['name'] == 'Latitude':
> lat = dic['value']
> if dic['name'] == 'Longitude':
> lng = dic['value']
> protoMarker['lat'] = lat
> protoMarker['lng'] = lng
> protoMarker['tooltip']['content']['text'] = name
> markers.append(protoMarker)
> 	
> return markers
> 
> ```

How it works:

- The initial binding brings in `this.custom.vehicleStatus`. That gets passed to the script transform as **value**.
- We read in `self.custom.sampleMarker` as a template for constructing the list of markers. Due to the way Jython works we need to make a deepcopy of it (otherwise all the markers will be set to the last value). See the article referenced in the script to understand more.
- Loop through your GPS data and find the name, lat and lng of each vehicle. Note that dictionaries are unordered so we need a loop. Since your data will be short a simple loop is adequate and readable.
- Update the copy of the template and add it to the list of markers.

---

_[View the full topic](https://forum.inductiveautomation.com/t/map-marker-in-perspective/90276)._
