WordPress.org

Forums

[resolved] Google Maps API (2 posts)

  1. wowzimmer
    Member
    Posted 2 years ago #

    I've been trying to get Google Maps to load in individual posts using the Google API but the map ends up broken every time!

    I know the Javascript is sound - when I load it on a plain HTML page it works perfectly.

    I understand that loading Javascript can be a little more complicated in WordPress. I have finally learnt how to register and enqueue the Google Maps API javascript libraries and that is sitting nicely in this themes functions.php file.

    I have created a couple of .js files for two maps and referenced them in my themes header.

    In the WordPress posts I have simply used the CSS classes for the two maps to call the javascript. But every time, the map just doesn't work properly. The infoboxes don't open properly, the street view pegman disappears and a multi-coloured box appears in the middle of the map.

    I've tried loading the javascript file directly in the post and even pasting all the javascript directly into the post. I still get the same problem.

    In terms of trouble shooting I've already switched my theme back to twentytwelve and twentyeleven but it makes no difference.

    Does anybody know what I might be missing here? It's caused me a significant amount of grief so far and I am no further forward!!!!

    Many thanks

  2. wowzimmer
    Member
    Posted 2 years ago #

    #map img{max-width: inherit;}

    Got the answer from StackOverflow. Was convinced that I had messed up loading the Javascript into WordPress as it seems like such a complicated task compared to basic HTML. I hadn't even considered CSS but am pleased to report that this did the trick!

Topic Closed

This topic has been closed to new replies.

About this Topic