Ox.Map: Add loading icon (for geocode requests)
This commit is contained in:
parent
e83db23056
commit
eb1b8c8745
1 changed files with 12 additions and 16 deletions
|
@ -317,27 +317,21 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(self.$toolbar);
|
.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({
|
self.$findInput = Ox.Input({
|
||||||
clear: true,
|
clear: true,
|
||||||
placeholder: self.options.findPlaceholder,
|
placeholder: self.options.findPlaceholder,
|
||||||
width: 192
|
width: 192
|
||||||
})
|
})
|
||||||
.css({float: 'right', margin: '4px'})
|
.css({float: 'right', margin: '4px 4px 4px 2px'})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
submit: submitFind
|
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()
|
self.$map = Ox.Element()
|
||||||
|
@ -743,16 +737,16 @@ Ox.Map = function(options, self) {
|
||||||
// gets the largest place at latlng that would fit in bounds
|
// gets the largest place at latlng that would fit in bounds
|
||||||
var callback = arguments.length == 3 ? callback : bounds,
|
var callback = arguments.length == 3 ? callback : bounds,
|
||||||
bounds = arguments.length == 3 ? bounds : null;
|
bounds = arguments.length == 3 ? bounds : null;
|
||||||
|
self.$loadingIcon.start();
|
||||||
self.geocoder.geocode({
|
self.geocoder.geocode({
|
||||||
latLng: latlng
|
latLng: latlng
|
||||||
}, function(results, status) {
|
}, function(results, status) {
|
||||||
//Ox.Log('Map', 'results', results)
|
self.$loadingIcon.stop();
|
||||||
var length = results.length;
|
|
||||||
if (status == google.maps.GeocoderStatus.OK) {
|
if (status == google.maps.GeocoderStatus.OK) {
|
||||||
if (bounds) {
|
if (bounds) {
|
||||||
Ox.forEach(results.reverse(), function(result, i) {
|
Ox.forEach(results.reverse(), function(result, i) {
|
||||||
if (
|
if (
|
||||||
i == length - 1 ||
|
i == results.length - 1 ||
|
||||||
canContain(bounds, result.geometry.bounds || result.geometry.viewport)
|
canContain(bounds, result.geometry.bounds || result.geometry.viewport)
|
||||||
) {
|
) {
|
||||||
callback(new Ox.MapPlace(parseGeodata(results[i])));
|
callback(new Ox.MapPlace(parseGeodata(results[i])));
|
||||||
|
@ -779,9 +773,11 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPlaceByName(name, callback) {
|
function getPlaceByName(name, callback) {
|
||||||
|
self.$loadingIcon.start();
|
||||||
self.geocoder.geocode({
|
self.geocoder.geocode({
|
||||||
address: name
|
address: name
|
||||||
}, function(results, status) {
|
}, function(results, status) {
|
||||||
|
self.$loadingIcon.stop();
|
||||||
if (status == google.maps.GeocoderStatus.OK) {
|
if (status == google.maps.GeocoderStatus.OK) {
|
||||||
callback(new Ox.MapPlace(parseGeodata(results[0])));
|
callback(new Ox.MapPlace(parseGeodata(results[0])));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue