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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Danny Luna](https://secure.gravatar.com/avatar/e56c84d2dc537a235258fbf3f825c10d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Danny Luna
5,899 PointsEnable pinch zoom on google map for mobile device
How do i enable pinch zoom on iOS device. Everything works fine, i just need for users to be able to pinch zoom on the map only:
heres what i have:
HTML:
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, , user-scalable=yes">
<div id="map-canvas"></div>`
CSS:
#map-canvas {
margin: 1em auto;
width: 90%;
height: 9em;
}
JS:
//Google Map API
function initialize() {
var mapCanvas = document.getElementById('map-canvas');
var map = new google.maps.Map(mapCanvas);
var isDraggable = $(document).width() > 480 ? true : false; // If document (your website) is wider than 480px, isDraggable = true, else isDraggable = false
var myLatlng = new google.maps.LatLng(26.754051, -80.920592);
var mapOptions = {
center: myLatlng,
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: isDraggable,
scrollwheel: false, // Prevent users to start zooming the map when scrolling down the page
//... options options options
panControl: true,
scaleControl: true
}
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Hello World!'
});
}
google.maps.event.addDomListener(window, 'load', initialize);`