Ox.Map: don't fail when calling panToPlace, selectPlace or zoomToPlace before places have loaded
This commit is contained in:
parent
3687620814
commit
a4fedfd924
1 changed files with 23 additions and 8 deletions
|
@ -1033,9 +1033,16 @@ Ox.Map = function(options, self) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function panToPlace() {
|
function panToPlace() {
|
||||||
var place = getSelectedPlace();
|
var place;
|
||||||
|
if (!self.loaded) {
|
||||||
|
setTimeout(function() {
|
||||||
|
panToPlace();
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
place = getSelectedPlace();
|
||||||
place && self.map.panTo(place.center);
|
place && self.map.panTo(place.center);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function parseGeodata(data) {
|
function parseGeodata(data) {
|
||||||
var bounds = data.geometry.bounds || data.geometry.viewport,
|
var bounds = data.geometry.bounds || data.geometry.viewport,
|
||||||
|
@ -1172,12 +1179,13 @@ Ox.Map = function(options, self) {
|
||||||
|
|
||||||
function selectPlace(id, zoom) {
|
function selectPlace(id, zoom) {
|
||||||
// id can be null (deselect)
|
// id can be null (deselect)
|
||||||
var place, selected = getSelectedMarker();
|
var place, selected;
|
||||||
if (!self.loaded) {
|
if (!self.loaded) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
selectPlace(id, zoom)
|
selectPlace(id, zoom);
|
||||||
}, 1000);
|
}, 100);
|
||||||
} else {
|
} else {
|
||||||
|
selected = getSelectedMarker();
|
||||||
Ox.Log('Map', 'Ox.Map selectPlace()', id, selected);
|
Ox.Log('Map', 'Ox.Map selectPlace()', id, selected);
|
||||||
if (id != selected) {
|
if (id != selected) {
|
||||||
place = getPlaceById(selected);
|
place = getPlaceById(selected);
|
||||||
|
@ -1222,7 +1230,7 @@ Ox.Map = function(options, self) {
|
||||||
self.options.selected = id;
|
self.options.selected = id;
|
||||||
setPlaceControls(place);
|
setPlaceControls(place);
|
||||||
setStatus();
|
setStatus();
|
||||||
that.triggerEvent('selectplace', place); // DEPRECATED
|
that.triggerEvent('selectplace', place); // FIXME: DEPRECATED
|
||||||
that.triggerEvent('select', {place: place});
|
that.triggerEvent('select', {place: place});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1429,9 +1437,16 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoomToPlace() {
|
function zoomToPlace() {
|
||||||
var place = getSelectedPlace();
|
var place;
|
||||||
|
if (!self.loaded) {
|
||||||
|
setTimeout(function() {
|
||||||
|
zoomToPlace();
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
place = getSelectedPlace();
|
||||||
place && self.map.fitBounds(place.bounds);
|
place && self.map.fitBounds(place.bounds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
addPlace <f> addPlace
|
addPlace <f> addPlace
|
||||||
|
|
Loading…
Reference in a new issue