1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to show Google-Map as user-specific website background ?

Discussion in 'Off Topic' started by erich37, May 20, 2013.

  1. erich37

    erich37 Well-Known Member

    if you go to this website, it will show a background-image of "Google Maps" which is showing the street-map of your very own city.
    So it seems it is somehow pulling the IP of the user and then showing a local map.

    How to do something like that ?

    http://shpock.com



    :)
     
  2. Tracy Perry

    Tracy Perry Well-Known Member

    Actually it's not... I went there and it shows that I'm near Dealey Plaza Park in Dallas... and I'm a GOOD 140 miles from there. ;)
    I imagine they have a script using GeoIP capability, check the IP of the visitor and then link it to google maps (much like Digital Point User Map).
    http://blog.wadehammes.com/post/3837158298
    http://blog.teamtreehouse.com/getting-started-with-the-geolocation-api
     
  3. 0ptima

    0ptima Well-Known Member

  4. Tracy Perry

    Tracy Perry Well-Known Member

    You mean like this? :D
    PHP:
    #!/bin/sh
     
    GEOIP_MIRROR="http://geolite.maxmind.com/download/geoip/database"
    GEOIPDIR=/usr/share/GeoIP
    #GEOIPDIR=/tmp/geoip
    TMPDIR=
     
    EMAIL_TO="tdperry@ride-texas.org"
    EMAIL_SUBJECT="[WARNING] GeoIP update error"
    EMAIL_HEAD="Oh Worthy One,"
    EMAIL_CONTENT="There was an error updating the following GeoIP databases:"
    EMAIL_FIX="Don't forget to launch a new update manually. No new automatic update will be done until next month!"
    EMAIL_FOOT="Your Slave, from Palestine, TX (USA)."
    EMAIL_META="VM: server_name - DNS: server_domain.tld - DC: server_datacenter"
    EMAIL_BUGGY=""
     
    DATABASES="GeoLiteCity GeoLiteCountry/GeoIP"
     
    if [ -"${GEOIPDIR}]; then
                    cd $GEOIPDIR
     
                    
    if [ -"${DATABASES}]; then
                                    TMPDIR
    =$(mktemp -d geoipupdate.XXXXXXXXXX)
     
                                    echo 
    "Updating GeoIP databases..."
     
                                    
    for db in $DATABASES; do
                                                    
    fname=$(basename $db)
     
                                                    
    wget --no-verbose -t 3 -T 60 "${GEOIP_MIRROR}/${db}.dat.gz" -"${TMPDIR}/${fname}.dat.gz"
     
                                                    
    if [ "$?" "0" ]; then
                                                                    gunzip 
    -fdc "${TMPDIR}/${fname}.dat.gz" "${TMPDIR}/${fname}.dat"
                                                                    
    mv "${TMPDIR}/GeoLiteCity.dat" "${GEOIPDIR}/GeoIPCity.dat"
                                                                    
    mv "${TMPDIR}/${fname}.dat" "${GEOIPDIR}/${fname}.dat"
                                                                    
    chmod 0644 "${GEOIPDIR}/${fname}.dat"
                                                    
    else
                                                                    if [ 
    "${EMAIL_BUGGY}"" ]; then
                                                                            EMAIL_BUGGY
    =$db
                                                                    
    else
                                                                            
    EMAIL_BUGGY=${EMAIL_BUGGY}", $db"
                                                                    
    fi
                                                    fi
                                    done
     
                                    
    [ -"${TMPDIR}] && rm -rf $TMPDIR
     
                                    
    if [ "${EMAIL_BUGGY}!= "" ]; then
                                            
    echo "${EMAIL_HEAD}\n\n${EMAIL_CONTENT} ${EMAIL_BUGGY}\n\n${EMAIL_FIX}\n\n\n${EMAIL_FOOT}\n\n\n${EMAIL_META}| /usr/bin/mail -"${EMAIL_SUBJECT}" "${EMAIL_TO}"
                                    
    fi
                    fi
    fi
     
    0ptima likes this.
  5. 0ptima

    0ptima Well-Known Member

    Nice :). Ive been manually updating the database every now and then. This is much better :)
     
  6. Adam Howard

    Adam Howard Well-Known Member

    The drawback is if it can't find you, it doesn't look so nice

    (click on thumbnail to enlarge)
     

    Attached Files:

  7. erich37

    erich37 Well-Known Member

    yeah, I saw that as well.
    make the screen-size of your browser smaller... then I guess it shows up.
     
  8. Adam Howard

    Adam Howard Well-Known Member

    Smaller, bigger, no change...

    I think there maybe something preventing it from loading correctly. Going directly to Google maps though and everything loads fine (see attached).

    It's a cool trick, but something to be mindful of anyone who tries to repeat it.
     

    Attached Files:

Share This Page