Google Maps JavaScript StreetView bug
Asked Answered
L

3

14

The newest release version of the Google Maps JavaScript (3.32.13) is conflicting with Prototype.js version 1.7.3.

When I have Prototype included on the page, the Street View of Google Maps will not handle mouse drags to "look around"

Is this a known issue? Any workarounds?

Lacewing answered 18/5, 2018 at 20:18 Comment(2)
I also have the situation you are talking about - I'm attempting to figure out why the events are not firing.Catechist
Probably Prototype.js polyfills some objects or functions that were included in ES6 standard. I've seen some issues with prototype and Google maps api due to Function#bind.Abdullah
C
13

So the problem is that PrototypeJS is overwriting Array.from as an alias to $A() which creates an extended Array object.

IF (big IF) you are not using Array.from to create a shallow copy of an array and expecting the Prototype extended methods, you can remove/comment out the line in prototype.js that is only

Array.from = $A;

In my copy of 1.7.3 it is line 1114

Catechist answered 29/5, 2018 at 23:1 Comment(1)
Thank you! I was not relying on prototype.js's Array.from. This worked!Lacewing
B
8

I also struggled with the conflict between Prototype.js and Google API. Removing Prototype.js was not an option as it is deeply engrained in the project. I decided to replace

Array.from = $A;

by

Array.from = Array.from || $A;

in the prototype.js file. It keeps the support for older browsers which do not have Array.from implemented natively. This does not solve the conflict between Prototype.js and Google API on older browsers though!

This site overrides Array.from() with an implementation that doesn't support iterables, which could cause Google Maps JavaScript API v3 to not work correctly.

Byelorussian answered 8/2, 2021 at 9:57 Comment(0)
R
3

I also have the same issue. So, I reopened a relevant GM API tkt: https://issuetracker.google.com/issues/72690631

I tried to rename the function collect into prototype.js but it didn't work.

Raving answered 21/5, 2018 at 8:34 Comment(1)
Thank you for drawing attention to this!Lacewing

© 2022 - 2024 — McMap. All rights reserved.