Using geoJson in perspective map

I’m been looking at the perspective Map and wanted to use it to track the location of a gps device showing a line from its starting point to its ending point. After some initial testing, it seems like I have two possible ways to do this

  1. Take my historical tracking of lat/long and feed that into a geoJson object.
  2. For each change in my lat/long add a new polyline entry under the vector entry (which is under layers).

For 1, what the proper way to add a geoJson entry? I’ve tried to manually build out an entry with a single point, but nothing displays (or the map breaks completely).

For 2, is there a method on the map I can call to add a new polyline point during runtime whenever my latitude/longitude changes?

Depending on where your coordinates are coming from, I would probably create a custom property on the map or view containing the map that is bound in such a way that it updates its value with the new coordinates whenever they change, then use a property change script on that custom property to grab the list of polyline coordinates, and append a new instance of coordinates to it containing the updated coordinates. In case that doesn’t make much sense, I’ve attached a test view that does this from the Map.custom.latlng property you can play with. In this view, the lat/lng values are coming from a string tag where lat and lng are simply separate by a comma in the value of the tag.

Map_Polyline.zip (233.1 KB)

1 Like

I’m looking at it now and it seems to be exactly what I was trying to figure out for method #2! I thought I had to add a new entry per point in the polyline, so it’s nice to see that I can just keep appending to the existing list. Once I test it out a little bit I’ll let you know if it did the trick :smiley:

1 Like