Ox.Map: Add loading icon (for geocode requests)

This commit is contained in:
rolux 2013-03-02 10:40:56 +05:30
parent e83db23056
commit eb1b8c8745

View file

@ -317,27 +317,21 @@ Ox.Map = function(options, self) {
}
})
.appendTo(self.$toolbar);
/*
self.$labelsButton = Ox.Checkbox({
title: 'Labels',
width: 64
})
.css({float: 'left', margin: '4px'})
.bindEvent({
change: toggleLabels
})
.appendTo(self.$toolbar)
*/
self.$findInput = Ox.Input({
clear: true,
placeholder: self.options.findPlaceholder,
width: 192
})
.css({float: 'right', margin: '4px'})
.css({float: 'right', margin: '4px 4px 4px 2px'})
.bindEvent({
submit: submitFind
})
.appendTo(self.$toolbar)
.appendTo(self.$toolbar);
self.$loadingIcon = Ox.LoadingIcon({
size: 16
})
.css({float: 'right', margin: '4px 2px 4px 2px'})
.appendTo(self.$toolbar);
}
self.$map = Ox.Element()
@ -743,16 +737,16 @@ Ox.Map = function(options, self) {
// gets the largest place at latlng that would fit in bounds
var callback = arguments.length == 3 ? callback : bounds,
bounds = arguments.length == 3 ? bounds : null;
self.$loadingIcon.start();
self.geocoder.geocode({
latLng: latlng
}, function(results, status) {
//Ox.Log('Map', 'results', results)
var length = results.length;
self.$loadingIcon.stop();
if (status == google.maps.GeocoderStatus.OK) {
if (bounds) {
Ox.forEach(results.reverse(), function(result, i) {
if (
i == length - 1 ||
i == results.length - 1 ||
canContain(bounds, result.geometry.bounds || result.geometry.viewport)
) {
callback(new Ox.MapPlace(parseGeodata(results[i])));
@ -779,9 +773,11 @@ Ox.Map = function(options, self) {
}
function getPlaceByName(name, callback) {
self.$loadingIcon.start();
self.geocoder.geocode({
address: name
}, function(results, status) {
self.$loadingIcon.stop();
if (status == google.maps.GeocoderStatus.OK) {
callback(new Ox.MapPlace(parseGeodata(results[0])));
}