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
Justin Beck
Courses Plus Student 4,329 PointsGoogle Maps Integration > Adding Point Markers Zoom Malfunction
Hello, great site I'm learning alot!
Every day after I do the lessons I try out what I've learned on my own localhost website i'm building.
I added the google map to my site like we did in the video.
However, I only had one address and when the map loaded it was fully zoomed in. I verified the mapOptions zoom was set the same as the video.
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
I verified changing the other options had an effect. I could change the center coordinates as well as the mapTypeId but the zoom had no effect.
As a further test, I used the downloaded project files for Smells Like Bacon and loaded up the locations.html in chrome and sublime text 3. I then removed one of the address elements so that there would be only one marker displayed.
Upon reloading the browser page for locations.html it displayed the same fully zoomed in characteristics.
I spent several hours today googling and trying to find out why it seems that the zoom option is being overwritten with a zoom value of 21, but I was unsuccessful being the js novice that I am. :)
I was wondering if anyone else had encountered this and could explain it to me?
Thanks, Justin
1 Answer
Christer Nordbø
2,133 PointsI have ran into this sort of problem before, only i have never used Google Maps API.
But there is a posibility that you could manually trigger some sort of setZoom() function on the map object.
I honestly got to say that i did not find the solution of making the zoom property work on initialization!