Google maps - drawing lines between locations

0
Hey guys, here’s what I would like to achieve: Lines between points. I tried the widget “Advanced Google Maps Widget Only” though I couldn’t set it up successfully, I think it needs an update. When I tried to set the latitude of the marker, I just couldn’t select the attribute “Latitude”   GoogleMaps Custom Marker works, though it’s functionality is still different from what I want to achieve. Does anyone have any thoughts on this? Or perhaps can point me in the right direction, or has even done/fixed this before: I’m all ears!
asked
2 answers
0

So that everybody knows in the future: This feature is now available in the updated GoogleMaps CustomMarker v2.0.0 widget in the AppStore. Thanks to Shana Lai from your company for sharing!

 

answered
2
  1. Create a Polyline entity in your database with an unlimited string attribute called something like CoordinatesArray.
  2. In this attribute store the array of x and y coordinates you want to plot on Google Maps. Use a format in which you can distinct separate Points of the Polyline and separate coordinates. So, a line consisting of two points X1,Y1 and X2,Y2, could be stored like something like (X1,Y1),(X2,Y2) as a string.
  3. Alter either Google Maps widget to make sure this attribute will be available in the widget.
  4. Before actually creating the Marker in one of the Marker widgets, make sure you split this coordinatesarray attribute with javascript into an array of points to create a thing which the Google API refers to as a Path;
  5. Instead of creating a marker with a Point, create a Polyline with a Path, see:https://developers.google.com/maps/documentation/javascript/examples/polyline-simple
  6. See specifically the part where the flightPath is created;

 

A bit of a challenge, but nothing too complicated if you alter an existing widget handling markers. Going from the CoordinatesArray to the Path is the trickiest part I would say.

Good luck!

answered