From eb1b8c874565eca1fe6a6811b93e64b060c978c9 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 2 Mar 2013 10:40:56 +0530 Subject: [PATCH] Ox.Map: Add loading icon (for geocode requests) --- source/Ox.UI/js/Map/Map.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/source/Ox.UI/js/Map/Map.js b/source/Ox.UI/js/Map/Map.js index cd9f5bfa..efdded3f 100644 --- a/source/Ox.UI/js/Map/Map.js +++ b/source/Ox.UI/js/Map/Map.js @@ -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]))); }