Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

In the "mapOptions" object set the "center" key to a new google.maps namespaced "LatLng" object with the arguments of 28.42 and -81.58

I do not understand why this show "null".

<script id="map" type="text/javascript"> var mapOptions = { center: new google.maps.LatLng(28.42, -81.58) };

thanks

5 Answers

Jay Goettelmann
Jay Goettelmann
1,368 Points

Hi Paulo,

What exactly is returning null?

In the code above you are creating a new object with one property/key named 'center'. You are assigning that object to the variable mapOptions. Therefore, if you are trying to access some other property of mapOptions e.g. mapOptions.scale or mapOptions.zoom you will receive undefined. (Not sure if that is what is actually causing your problem or not.)

I think you probably need to assign the new LatLng object to mapOptions.center i.e.

mapOptions.center = new google.maps.LatLng(...);

Otherwise, if mapOptions truly is a new object with no other properties, your code should work when you try to access mapOptions.center.

var mapOptions = { center: new google.maps.LatLng(28.42, -81.58) }; is returning null.

I tried your solution but it still null.

When I start the exercise,it looks like this "var mapOptions = {};".

Thank you for your answer.

Jay Goettelmann
Jay Goettelmann
1,368 Points

Which course/challenge is this from?

Build an Interactive Website/ Google Maps Integration/ Adding a Dynamic Map 7 objectives.

Jay Goettelmann
Jay Goettelmann
1,368 Points

Paulo,

I was able to pass the task with the following:

var mapOptions = {
    center: new google.maps.LatLng(28.42, -81.58)
};

I wonder if you have a problem somewhere else in your solution?