SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Google map as BG not showing

    So, I'm trying to get the google map to set it as a background on my test contact us page. http://www.connect4webdesign.com/maptest/

    I'm getting a couple of errors in the js console, but I believe once I fix the first error that the others will be corrected.

    This is the error message which I'm getting, "Uncaught SyntaxError: Unexpected end of input"

    The error is related to the last line


    Code:
    jQuery(document).ready(function() {
     
     var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(40.442157, -111.774539),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
      
    }
    What is wrong here?
    Last edited by Pullo; Jun 28, 2014 at 00:40. Reason: Code tags

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    Out of interest why not just save the relevant part of the Google map as an image and use it as a background?

  3. #3
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,002
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by BrianBam View Post
    What is wrong here?
    Missing closing bracket and semi-colon.

    Code:
    jQuery(document).ready(function() {
     
     var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(40.442157, -111.774539),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
      
    }); <---- here

  4. #4
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rubble View Post
    Out of interest why not just save the relevant part of the Google map as an image and use it as a background?
    I just see that it is the more modern thing to do on contact pages and I'm thinking that others are going to ask me to do it for the at some point so I thought I'd do it on my site first.

  5. #5
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Pullo. That got the map to show and now I have to tweak a few css rules. I did try it with the semicolon, but forgot the parentheses #Doh. #NewTojQuery

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,002
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    No problems

    A good tool to catch errors like this is JSHint.
    You copy and paste your code there and it will inform you of any errors it finds.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •