Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maps.googleapis.com incompatible with date.js

Recently encountered a problem with a long standing asp.net c# program.

In my default.aspx amongst other things we have...

<script src="https://maps.googleapis.com/maps/api/js?key=...&libraries=geometry"></script>

<script src="/js/date.js" type="text/javascript"></script>

date.js is a utility library from http://www.datejs.com/

Just recently (last 6 weeks) our map is failing to draw anything, after a bit of investigation it seems that there's a toString() in one of the maps library files that tries to use the toString() from the date.js file and fails miserably.

Uncaught TypeError: format.replace is not a function
    at Date.toString (date.js:40)
    at iq (common.js:65)
    at Object._.Bq (common.js:75)
    at map.js:83

For the moment I can specify the version of google maps, 3.40 works fine, anything later doesn't.

Does anyone have a solution to this or has anyone seen this problem? Granted date.js is very old library now but I wondered if there's anything simply I can do.

like image 902
Richard Nixon Avatar asked Aug 04 '20 21:08

Richard Nixon


People also ask

Why is my Google Maps API not working?

There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.

How can I tell if Google Maps API is working?

Go to the Credentials section, which can be accessed from the left side bar under Google Maps Platform > Credentials. Check that the API key you currently use on your website is listed.

Is Google Maps API no longer free?

You won't be charged until your usage exceeds $200 in a month. Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).

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.

When will the maps JavaScript API release a new version?

Once per quarter, the Maps JavaScript API team releases a new version. This happens mid-February, mid-May, mid-August, and mid-November. The next update will be mid-November . The new weekly channel will provide version 3.47 , and at that time the other channels will be updated.

How do I use the maps JavaScript API client side services?

To use the Maps JavaScript API client side services, you will need to create a separate API key which can be secured with an HTTP referrers restriction (see Get, add, and restrict an API key ). To help you get your maps code up and running, Brendan Kenny and Mano Marks point out some common mistakes and how to fix them in this video.

How do I change the version of Google Maps API?

Open the console in your browser developer tools, and look at the value of google.maps.version. Update the script tag that loads the API, and request an older version number . For example, if google.maps.version is "3.46.2", use v=3.45 in your script tag.


Video Answer


3 Answers

Google suggests pointing to a more recent version of date.js https://github.com/datejs/Datejs/issues/88

I haven't checked it yet but confirmed it is failing with an old date.js

like image 175
Jorge Cossio Avatar answered Oct 19 '22 03:10

Jorge Cossio


I am also getting the same error in version 3.41, but after changing it to version 3.40, It works!

like image 31
Arjun Yadav Avatar answered Oct 19 '22 03:10

Arjun Yadav


Ran into this same issue in a Rails app, updating data.js to a more recent version fixed it. There's a more recent fork that's available here that fixed the issue for me: https://github.com/abritinthebay/datejs

like image 2
Caleb Rainey Avatar answered Oct 19 '22 03:10

Caleb Rainey