TripPathImage exceeds Google Maps API maximum URL length

  • 2
  • Question
  • Updated 2 years ago
  • Answered
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members.

Not sure if you're aware, but it looks like Automatic is generating URLs well in excess of the Google Maps API's static maps url limit of 2048 characters. (https://developers.google.com/maps/do...). I can provide examples.
Photo of ed1chandler

ed1chandler

  • 1,120 Points 1k badge 2x thumb

Posted 2 years ago

  • 2
Photo of Leigh Meeker

Leigh Meeker

  • 440 Points 250 badge 2x thumb
Happens for me too. I've had success with trips less than ~10 miles or ~15 minutes, but any longer and it errors out.
Photo of ed1chandler

ed1chandler

  • 1,120 Points 1k badge 2x thumb
For context, I've got IFTTT writing lines to a Google Sheet when Automatic finishes a trip, then using a Google script to pick it up and create a calendar event (retroactively) so I can see when I was driving, etc.

I've been reading up on the polyline algorithm and I think the way to go here is to just recursively downsample the points.  i.e. Convert the polyline back to coordinates, then remove every Nth point until the total URL drops below 2048.

I just taught myself javascript last week, so it'll take me a while to figure that out, but *somebody* out there (cough) could probably figure that out a lot quicker.
Photo of Amy

Amy

  • 68,970 Points 50k badge 2x thumb
Ok, thanks for the report on this. I'm reaching out to our primary developer who worked on our platform API and apps. He's travelling internationally right now so it may be a few days before we hear back. 
Photo of Amy

Amy

  • 68,970 Points 50k badge 2x thumb
Luckily, we caught him at a good time and I heard back already. So he says that unfortunately, the issue is on IFTTTs end -- we can’t control it since we didn’t build the IFTTT integration. Ideally, they'd simplify our encoded paths so that they end up being short enough to fit inside google maps static API limits.

That being said, there might be something we can change on our end but I'll have to check in with our engineering team to see how viable it is. 
Photo of Amy

Amy

  • 68,970 Points 50k badge 2x thumb
Just to update this - the possible "hacky" fix that I was looking into isn't going to work. I'll explain more below. 
Photo of ed1chandler

ed1chandler

  • 1,120 Points 1k badge 2x thumb
Okay, that makes sense.  Without knowing what information you're passing to IFTTT, one suggestion would be to downsample the number of coordinate pairs passed along to some maximum that ensures that the polyline conversion can't expand beyond 2048 characters. I'm guessing somewhere around 300 would be safe.

For those of you in the same boat as I am, the linked text file contains a JavaScript function that will downsample the polyline until the URL is less than 2048 characters long.  This is quite literally my second week of fooling around with .js, so feedback is welcome.
:-)

https://dl.dropboxusercontent.com/u/2372240/reducePolylineUrl.txt
(Edited)
Photo of Christopher Maujean

Christopher Maujean

  • 112 Points 100 badge 2x thumb
This reply was created from a merged topic originally titled Broken map link in IFFT / Trip -> Google Drive.

IFTT export trip to google drive has a broken map link in the TripPathImageMapURL field.
Photo of Amy

Amy

  • 68,970 Points 50k badge 2x thumb
Hi Christopher. I think this conversation is pertinent to the issue you were running into. Please see ed1chandler's suggestion right above. 
Photo of ed1chandler

ed1chandler

  • 1,120 Points 1k badge 2x thumb
Yep, I'd almost guarantee that's it.  Christopher, let me know if that's not going to work for you.  I've also submitted a ticket with IFTTT and pointed them to this thread.
Photo of Amy

Amy

  • 68,970 Points 50k badge 2x thumb
To give a bit more context to the challenge with this and any other suggestions our customers have for our IFTTT channel...

IFTTT used to build partner integrations. They built ours. This means that they have control of our IFTTT integration and any changes needed would have to be done by them. However, they are no longer in the business of building integrations for others. They're willing to maintain the one they built us for now but they're understandably unable to do any further development on it. So, for us to make any change to our IFTTT integration means that we need to rebuild the entire thing from scratch ourselves and then we can maintain it, tweak it, add to it as we please. This is a thing we would love to do and hope to do someday. Unfortunately, we don't have the available resources currently to do this.

So thank you, ed1chandler, for being so resourceful with this particular issue and figuring out (and sharing!!!) a workaround!

This conversation is no longer open for comments or replies.