jquery - Use variables outside the function -
below getting long/lat address google api. variables longitude , latitube need use gmap. creating map_canvas.
how done use these variables in next function? (where long/lat written per numbers)
jquery:
var geocoder = new google.maps.geocoder(); var address = markerinformation = $('#googlemaplocation').val(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { latitude = results[0].geometry.location.lat(); longitude = results[0].geometry.location.lng(); } }); markerinformation = $('#googlemapinformation').val(); $(function() { demo.add(function() { $('#map_canvas').gmap({'center': '57.7973333,12.0502107', 'zoom': 10, 'disabledefaultui':true, 'callback': function() { var self = this; self.addmarker({'position': this.get('map').getcenter() }).click(function() { self.openinfowindow({ 'content': markerinformation }, this); }); }}); }).load(); });
you can in 2 ways 1 turn them global variables removing reserved word var
before variable name.
or call function inside function
Comments
Post a Comment