Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setMaps() {
- var geocoder = new google.maps.Geocoder();
- var result = "";
- $('.map_canvas').each(function(){
- geocoder.geocode( {
- 'address': $(this).attr('address'),
- 'region': 'de'
- }, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- result += results[0].geometry.location.lng()+",";
- result += results[0].geometry.location.lat();
- } else {
- result = "Unable to find address: " + status;
- }
- $(this).gmap({ 'center': result });
- });
- });
- }
- <div class="map_canvas" address="Berlin, Zoo">
- </div>
- Uncaught TypeError: Cannot set property 'position' of undefined
- function setMaps() {
- var geocoder = new google.maps.Geocoder();
- var result = "";
- $('.map_canvas').each(function(){
- var _this = $(this); // <------ here
- geocoder.geocode( {
- 'address': $(this).attr('address'),
- 'region': 'de'
- }, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- result += results[0].geometry.location.lng()+",";
- result += results[0].geometry.location.lat();
- } else {
- result = "Unable to find address: " + status;
- }
- _this.gmap({ 'center': result }); // <---- and here
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement