1

I'm building a site for a customer who wants a map on their "About Us" page showing their locations. I have the map working and fully functional on the desktop site (www.al-van.org/jake/aboutUs.html) using the Google Maps Javascript API. Everything is going good but when I try to view the site on my android device, I just get an "Oops something went wrong see the error console for more technical information" which doesn't help me a whole lot. I can't seem to figure out what is going on and why it won't work on mobile. I need to use the Javascript API because the client wants 2 locations on the map and the embed api won't do that. Here is my JS, the HTML is a simple div with a bootstrap framework.

<script>
    function initMap()
    {
        var map = new google.maps.Map(document.getElementById('map'), {
            zoom: 16,
            center: {lat: 42.389795, lng: -86.258617},
            styles: [
                {elementType: 'geometry'},
                {elementType: 'labels.text.stroke'},
                {elementType: 'labels.text.fill'}
            ]
        });
        // array used to label markers.
        var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        // Add some markers to the map.
        var markers = locations.map(function(location, i) {
            return new google.maps.Marker({
                position: location,
                label: labels[i % labels.length]
            });
        });
        // Add a marker clusterer to manage the markers.
        var markerCluster = new MarkerClusterer(map, markers, {imagePath: 
'googlemaps/m'});
    }
    var locations = [
        {lat: 42.390337, lng: -86.259642},
        {lat: 42.388635, lng: -86.257246}
    ]
</script>
<script src="googlemaps/markerclusterer.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js? 
 key=API_KEY&callback=initMap"></script>
5
  • You can always connect devtools to an android device via ADB over USB to see the error. Commented Jun 21, 2018 at 13:20
  • It's almost 100% certain that the error is reproducible on a desktop website, so just visit it on your PC and open up dev tools. Commented Jun 21, 2018 at 13:21
  • 1
    It works fine on my PC. No issues. I did have a similar issue that was fixed by enabling the correct API restriction but now that the Maps Javacript API is enabled, it should be working and it is on PC Commented Jun 21, 2018 at 13:23
  • @sylphaxiom Are you 100% positive the mobile site is loading the same HTML - i.e. is using the same API key (sounds like a dumb question, but double check)? Commented Jun 21, 2018 at 13:26
  • I only have one version of aboutUs.html uploaded to the server. I had a friend with a different phone check it as well. He has the same error on his Pixel. It may be an issue with Android Chrome. Commented Jun 21, 2018 at 13:38

2 Answers 2

4

After working with Google Support, it seems that the issue is in the way that the android Chrome puts in the website. I had explicitly set my allowed HTTP referrers all including www.blahblahblah.com and various variations using wildcards. What I DID NOT DO was include a wildcard in place of the "www" When I placed my wildcard as blahblah.com it allowed it to work on the mobile phone. For some reason, unless you explicitly type "www.example.com" into your android Chrome browser, it will not auto-fill the "www." This is what solved my issue, I hope it helps in the future.

Sign up to request clarification or add additional context in comments.

1 Comment

This should be selected as correct answer. Otherwise, most people would skip reading it.
0

Your API key is invalid for the domain, or is over it's quota limit.

Go here: https://developers.google.com/maps/documentation/javascript/get-api-key

To get an API key for the domain you are using.

5 Comments

Negative. Brand new API key and this site is not public facing yet. I've been working with google to get it working on desktop. Now that it's working on desktop it still isn't working on mobile. But the API key is good unless there's another api library I need to enable to add api restrictions.
@sylphaxiom You're going to have to provide a link. The API key (or over quota) is the reason google displays that image. You said the website isn't public facing yet, are you accessing the same development domain on desktop (where it works) as your are on mobile (where it doesn't)?
I provided the link above in my post. It is running on the actual site server under a sub folder so the public doesn't find it unless they know where to navigate to. The site can be found at al-van.org/jake/aboutUs.html and yes, that's the same URL I use to access it on desktop.
@sylphaxiom - there's simply something missing from your description of the problem. For the record, I've accessed the link via an iPhone and it works fine.
Thanks, perhaps it is an issue with my mobile version of chrome. It works when I'm using PC chrome and when I resize the screen with the dev tools to simulate a phone width. I'm using a Note 8 with Chrome, it may be an issue specific to my phone. I will look into things on my end. The odd thing is that, you guys are right, it acts exactly like it did when I had an API issue. But that has been resolved and this shouldn't be happening. I was hoping there was an error in my code that made it no longer mobile responsive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.