Google map as fixed background like on foursquare

10,376

Here's a way you can do it: http://jsfiddle.net/X5r8r/927/

html, body {
    height:100%;
}

#map-container {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

#map
{
    width: 100%;
    height: 100%;
}
#content
{
    width: 200px;
    position: absolute;
    z-index: 1;
    top:0;
    left:0;
    border: 4px solid black;
    background:#fff;
    padding:20px;
}
Share:
10,376
warmspringwinds
Author by

warmspringwinds

http://warmspringwinds.github.io/

Updated on June 23, 2022

Comments

  • warmspringwinds
    warmspringwinds almost 2 years

    I'm trying to do something like this. I want to have google map as a fixed background and place my content(some text) on it as it's made on foursquare. Also i want to be able to scroll my content. This is my effort:

    #map
    {
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        z-index: 0;
    }
    #content
    {
        width: 200px;
        margin: auto;
        position: relative;
        z-index: 1;
        border: 4px solid black;
    }
    ​
    

    But the map disappears. Any help will be appreciated.

  • warmspringwinds
    warmspringwinds over 11 years
    Thans, but when i scroll down your map seems not to be fixed. I need map to react like here: foursquare.com/…
  • warmspringwinds
    warmspringwinds over 11 years
    Yes, this is it! Thanks, man) Correct your answer and i'll accept it.
  • Billy Moat
    Billy Moat over 11 years
    No worries, glad I could help.
  • warmspringwinds
    warmspringwinds over 11 years
    Oh, sorry, i was in hurry to accept your answer. In your solution you used static map, but i need dynamic. Here is your code with dynamic map: jsfiddle.net/X5r8r/925 unfortunately the same problem. Do you know how to solve it?
  • dube
    dube almost 11 years
    For the record: here is the API documentation for generating those images: developers.google.com/maps/documentation/staticmaps