WordPress.org

Ready to get started?Download WordPress

Forums

Google map as background (4 posts)

  1. amaanr
    Member
    Posted 1 year ago #

    Hey guys, I'm trying to get a dynamic Google map as my background? Does anyone know how to do this? What file needs to be edited specifically?

    Thanks in advance!

  2. bcworkz
    Member
    Posted 1 year ago #

    I don't think you can use it as a true background, it has to be contained in an html element. But you can have it fill the window and then use CSS to place all your other elements over it.

    Follow the Google Developer site examples using the Google Maps JavaScript API to add the needed script tags to your theme's header.php template. Then on which ever theme template pages will have the map displayed, add the appropriate div element to contain the map.

    Then modify your theme's CSS file for the desired effect.

  3. michael.mariart
    Member
    Posted 1 year ago #

    There's "easy" and "hard" ways of doing this.

    Firstly, do you want the map to be interactive? I mean with the zoom, changing location, etc? if you do, then you'll need to do it the hard way. You'd have to set up the page with a main area (most times in a <div> tag) that contains the map, and then set up the actual page content to go over the top of that using z-nidex values in your CSS. This might and might not work because there's a lot of CSS stuff going on in the Google Maps, so it's a big of a gamble.

    if you are happy with a static (non-changing) image as the background you can do this using the 'Static Maps API' instead. When you work out the URL for the map that you want you can set this as the background in your element through it's CSS styling, and everything should be able to overlay it easily.

    One thing to do beforehand is to check Googles terms of service before you do to much. I haven't read them much (or at all really...) but there's a chance that they could prohibit such activities as covering parts of their maps. It's not extremely likely, but it's a possibility so it's worth a little bit of reasearch just in case.

  4. amaanr
    Member
    Posted 1 year ago #

    Great, thanks guys!

    Yes, I was planning on having an interactive map. I'm going to give it a go and see what comes out of it.

Topic Closed

This topic has been closed to new replies.

About this Topic