Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps JavaScript StreetView bug

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?

like image 211
Drew LeSueur Avatar asked May 18 '18 20:05

Drew LeSueur


People also ask

What is the street view API for Google Maps?

The Maps JavaScript API provides a Street View service for obtaining and manipulating the imagery used in Google Maps Street View. This Street View service is supported natively within the browser. Although Street View can be used within a standalone DOM element, it is most useful when indicating a location on a map.

Can I use Street View within the browser?

This Street View service is supported natively within the browser. Although Street View can be used within a standalone DOM element, it is most useful when indicating a location on a map. By default, Street View is enabled on a map, and a Street View Pegman control appears integrated within the navigation (zoom and pan) controls.

How do I get Started with the Google Maps JavaScript API?

Before you begin: Before you start using the Maps JavaScript API, you need a project with a billing account and the Maps JavaScript API enabled. To learn more, see Get Started with Google Maps Platform . The Maps JavaScript API lets you customize maps with your own content and imagery for display on web pages and mobile devices.

How do I get Streetview panorama images?

Street View images are supported through use of the StreetViewPanorama object, which provides an API interface to a Street View "viewer.". Each map contains a default Street View panorama, which you can retrieve by calling the map's getStreetView() method.


3 Answers

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.

like image 178
PhoenixDev - KL Avatar answered Oct 16 '22 04:10

PhoenixDev - KL


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.

like image 21
Fragias Avatar answered Oct 16 '22 05:10

Fragias


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

like image 28
Geek Num 88 Avatar answered Oct 16 '22 03:10

Geek Num 88