Zubair sadiq
Zubair sadiq

Reputation: 500

I want to change zoom of google map in angular js when some location search in search box

At initialization

var mapOptions = {
    zoom: 6,
    center: new google.maps.LatLng(30.3753, 69.3451),
    mapTypeId: google.maps.MapTypeId.ROADMAP
}
 $scope.map = new google.maps.Map(document.getElementById('map'), mapOptions);

At search

 $scope.map.zoom = 10;   

currently I use this code but its not working, at initialization of google map zoom=6 that is working properly but when I want to change on search it is not working.

Upvotes: 0

Views: 348

Answers (2)

kmj
kmj

Reputation: 1

var mapOptions = { zoom: level, center: new google.maps.LatLng(30.3753, 69.3451), mapTypeId: google.maps.MapTypeId.ROADMAP } $scope.map = new google.maps.Map(document.getElementById('map'), mapOptions);

On Search, set level to some value. $Scope.level = 10

Upvotes: 0

Waqas Noor
Waqas Noor

Reputation: 921

use setZoom()..

at Search Make it $scope.map.setZoom(10)... I Hope It works

Upvotes: 1

Related Questions