Linking perspective map icons to pages?

Hi all, I need to know how to make map icons link users to another page on mouseclick. Is this doable?

I assume by “map icon” you mean a marker?

Use the onMarkerClick map event handler to do the stuff you want

I did see that in the literature when I was learning about maps, but I’m very green and I don’t know how to implement it. I don’t see that listed in the marker parameters.

This is what you get from the onMarkerClick event object:

{
  "lng": -121.156711578,
  "name": "bob",
  "properties": {},
  "lat": 38.658169172
}

So then you can do whatever you want to do with that info, e.g.

system.perspective.navigate(page=event.name)

Thank you!

Still having a hard time with this. I don’t have my marker defined under CUSTOM, but under Props/Layers/UI/Marker. I’ve got the name of the marker set as the path I want to navigate to, and the first line in my script as

self.props.layers.ui.marker = event

and the second as
system.perspective.navigate(page=event.name)
When I click on a map marker it does navigate, but to a page that can’t be displayed. “View Not Found
No view configured for this page”

@Benjamin_Gott did you configure the script as show in @nminchin picture’s?

Yes, I think so, but like I mentioned, since I’m using the marker element from the map tree under props, I have line 2 done a little differently. I’m not sure what to do with the code in curly brackets in @nminchin’s second post.

Capture

@nminchin’s code self.custom.marker = event just assigns the event value to a property where you can see what is in the event that you have available in the runAction script. You don’t actually want to assign the event to the marker. In other words; delete that line from your action.

For navigation line, see system.perspective.navigate - Ignition User Manual 8.1 - Ignition Documentation. To work as written, the marker’s name needs to be an exact match to the page URL you have setup for the view. See Pages in Perspective - Ignition User Manual 8.1 - Ignition Documentation. If you haven’t setup a page URL for the view, you won’t be able to navigate to it.

So its not exactly what you should type. He is just trying to show a method to do what you want.

I’m not super familiar with perspective and can often be wrong lol, but I will try.

One thing I’m not a fan of is you defining a variable inside where you are declaring a param to pass.

I would declare it outside and just past the variable into the ()
so instead of system.perspective.naviagte(page=event.name) it would be page = event.name system.perspective.navigate(page) not sure that it makes a difference Listen to @witman above.

Thanks for your attention to this. I have copied the path from the project browser to the name of the marker and changed the script as you described but still no success. I even tried http://google.ca/ as a marker name and still no dice. See attached:


2

You need to setup a page URL per Pages in Perspective - Ignition User Manual 8.1 - Ignition Documentation.

Also note per documentation linked above you need to use this function differently for the web URL you’re testing (note “url =” rather than “page =”):
system.perspective.navigate(url = "http://www.google.ca")

1 Like

No, I wasn’t using the URL I was using the path because I saw that its best to label your markers according to path in another doc.

After setting the marker name to the URL /charts instead of the path Page/Charts things are now working.

You have my sincerest thanks, have a great rest of your day.

2 Likes

I definitely agree with this and I do this myself mainly to keep the function call as short as possible, but my example was just trying to keep it as simple as possible :sweat_smile:

1 Like

There actually is an important difference, which isn’t related to perspective.

The first example would be using a keyword argument, which (arguably :thinking:) wouldn’t matter in this case. It isn’t actually assigning a value to a variable but is telling the function to use the value for the page argument.

system.perspective.navigate(page=event.name)

The second example does actually do a variable assignment

page=event.name
system.perspective.navigate(page)

A third way to do this would be to just pass event. name

system.perspective.navigate(event.name)

All three are functionally equivalent, with the exception that in the second example you now also have a page variable that could be used later on in the script.

Keyword arguments are an important concept in python (and some other languages). An example of where you would use one is setting the getKey argument in system.db.runPrepUpdate() without also providing other arguments, such as the transaction argument.

3 Likes

Derp, yes, I would use:

page = 'path/.../...'
system.perspective.navigate(page=page)

Lazy replying gets me in trouble!

2 Likes