jquery - why does geocomplete not trigger bounds_changed event? -
i have google map takes whole screen size. there top bar has geocomplete text field, can type in place name , map moves place. however, problem fails trigger bounds_changed event.
second problem is, when map first loads, can't drag (the hand icon doesn't appear). after move other place using geocomplete field i'm able drag map. following relevant code snippet i've used.
$(document).ready -> google.maps.event.addlistener window.map, "bounds_changed", -> // here fire ajax request retrieve data , display in custom overlay. if navigator.geolocation navigator.geolocation.getcurrentposition(set_user_location,error, { 'enablehighaccuracy' : 'true' }) set_user_location = (position) -> mapoptions = center: new google.maps.latlng(position.coords.latitude, position.coords.longitude) zoom: 14 window.map = new google.maps.map(document.getelementbyid("map-canvas"), mapoptions) $('.countries-dropdown').geocomplete map: '#map-canvas' mapoptions: { scrollwheel: true } bounds: true .bind 'geocode:result', (event,result) -> console.log 'result' console.log result .bind 'geocode:error', (event,result) -> console.log 'error'
please leave comment if above information not enough. thanks.
nevermind. fixed bug myself. needed give window.map object in place of selector. is, instead of this
$('.countries-dropdown').geocomplete map: '#map-canvas'
used this
$('.countries-dropdown').geocomplete map: window.map
Comments
Post a Comment