mxn.register('googlev3', { Geocoder: { init: function() { this.geocoders[this.api] = new google.maps.Geocoder(); }, geocode: function(query, rowlimit){ var me = this; var geocode_request_object = {}; if (typeof(query) == 'object') { // query is a LatLonPoint object (reverse geocode) if (query.hasOwnProperty('lat') && query.hasOwnProperty('lon')) { geocode_request_object.latLng = query.toProprietary(this.api); } // query is an address object else{ geocode_request_object.address = [ query.street, query.locality, query.region, query.country ].join(', '); } } // query is an address string else { geocode_request_object.address = query; } this.geocoders[this.api].geocode(geocode_request_object, function(results, status) { me.geocode_callback(results, status, rowlimit); }); }, geocode_callback: function(results, status, rowlimit){ if (status != google.maps.GeocoderStatus.OK) { this.error_callback(status); } else { var places = []; // Code Health Warning // Don't let the fact that the Google geocoder returns 'results' as an array // fool you. Google 'generally' returns a single value when geocoding address // lookups; multiple values 'may' be returned but only where there is ambiguity // See https://developers.google.com/maps/documentation/geocoding/#JSON for (i=0; i 0) { return_location.street = streetparts.join(' '); } return_location.point = new mxn.LatLonPoint(place.geometry.location.lat(), place.geometry.location.lng()); places.push(return_location); } if (places.length > rowlimit) { places.length = rowlimit; } this.callback(places); } } } });