By fonkap


2014-08-26 12:23:53 8 Comments

I have a web application based on RichFaces 3.3.3 that uses Google Maps (maps-api v3), that was working fine until recently.

Lately is failing to draw the map's user controls. Map is drawn fine but the controls don't appear, map type or zoom control, for example.

Investigating a little, it seems a compatibility problem with prototype.js.

If you simply add this line to the example in developers.google.com:

<script src="http://prototypejs.org/assets/2008/9/29/prototype-1.6.0.3.js"></script>

js console in chrome browser logs this:

Uncaught TypeError: undefined is not a function       prototype-1.6.0.3.js:641

And the user controls dissapear...

Somebody knows how to solve this problem??

Now I'm going to try to change prototype.js in richfaces for a more modern version... I'll update when I know more.

Thanks in advance!

--- UPDATE ---

  • Using production version of Google Maps solves the problem. Now is necessary explicitly put v=3 in src in script tag. Thanks Dr.Molle.
  • Updating prototypejs to (1.7.2). Works fine with experimental too. Thanks @eepete.

--- UPDATE 2 ---

  • Using v=3 isn't working anymore with richfaces 3.3.3 (prototype-1.6.0.3.js) if you need to use this old version of prototype, now you need to explicitly use v=3.17 in google maps.

In other words, use this in your page for backguards compatibility with prototype-1.6.0.3.js:

<script src="https://maps.googleapis.com/maps/api/js?v=3.17"></script>

4 comments

@AbidCharlotte49er 2015-03-11 20:00:33

This function at line number 629ish in prototype.js is causing the exception. Simply add try catch blocks as shown below. It works with any Google Maps API.

collect: function(iterator, context) {
  iterator = iterator ? iterator.bind(context) : Prototype.K;
  var results = [];
  try {
    this.each(function(value, index) {
      results.push(iterator(value, index));
    });
  } catch (err) {}
  return results;
}

@fonkap 2015-03-11 21:48:55

Thanks! I'll give it a try

@yiwei 2014-10-08 09:17:39

Change to version v3, the conflict with prototype will disappear, I have tried in my site, it works fine.

@giscommander1985 2014-09-11 17:28:50

Yes!! the solution for me was change the line from:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false" />

to

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&v=3" />

Thanks!!

@eepete 2014-08-26 15:10:03

I had the same problem this morning. Got the same error, controls like the zoom control would not render. I upgraded my prototype.js to the latest version (1.7.2) from version (1.7) and things worked again. Am using google maps api V3, the production version. Don't know if it was the newer version prototype.js or if Google changed something and then fixed something, but it's happy now.

@fonkap 2014-08-26 15:18:55

I think google changed something recently in the experimental version. You can recheck that you are really using release version of maps, I was using experimental without being aware. Maybe you need to add v=3 explicitly to your script tag , or maybe you have v=3.exp in the src and you have to remove the .exp part.

@fonkap 2014-08-26 15:20:24

Anyway if you can update 'prototype.js', it seems the best solution.

@eepete 2014-08-27 20:41:05

The script tag I'm using is: 'maps.googleapis.com/maps/api/js?sensor=false' so I'm guessing that should be the production version? If it was '..../js?v=3.exp?sensor=false' that would use the experimental. If I understand you correctly, it would be advisable to explicitly get the production version by using the tag '..../js?v=3?sensor=false'. I'll give that a try and thank you for your reply.

@fonkap 2014-08-28 07:11:16

Exactly! if you put 'maps.googleapis.com/maps/api/js?sensor=false' in a browser you'll see at the end of the response (a js file) the line: 'getScript("maps.gstatic.com/maps-api-v3/api/js/18/0/main.js‌​");' if you put 'maps.googleapis.com/maps/api/js?sensor=false&v=3' you'll see getScript("maps.gstatic.com/maps-api-v3/api/js/17/15/main.js‌​");. I think that 18/0 corresponds to experimental and 17/15 to production... I don't know why Google is now sending 18 by default... Anyway the problem is solved, I think I'm going to update the post and marking your answer as solution.

@Loris 2014-11-20 16:08:00

Just today an app I built that uses OpenLayers and google maps stopped working. Updating PrototypeJS from the ancient 1.7.rc3 to 1.7.2 did the trick!

Related Questions

Sponsored Content

17 Answered Questions

[SOLVED] Google Maps API 3 - Custom marker color for default (dot) marker

  • 2011-08-17 15:39:21
  • jackocnr
  • 363115 View
  • 281 Score
  • 17 Answer
  • Tags:   google-maps-api-3

12 Answered Questions

[SOLVED] Google Maps JS API v3 - Simple Multiple Marker Example

13 Answered Questions

[SOLVED] Launching Google Maps Directions via an intent on Android

31 Answered Questions

[SOLVED] Google Maps API v3: How to remove all markers?

6 Answered Questions

14 Answered Questions

3 Answered Questions

6 Answered Questions

[SOLVED] Google Map API v3 — set bounds and center

1 Answered Questions

1 Answered Questions

[SOLVED] C# webbrowser control - google map javascript problems

Sponsored Content