1
0
Fork 0
forked from 0x2620/oxjs

update list when editing place

This commit is contained in:
rolux 2011-05-29 19:44:48 +02:00
commit 25b86dd085
3 changed files with 78 additions and 32 deletions

View file

@ -389,7 +389,7 @@ Ox.Map = function(options, self) {
countryCode: '',
editable: true,
geoname: '',
id: '_' + Ox.uid(), // fixme: stupid
id: '_' + Ox.encodeBase32(Ox.uid()), // fixme: stupid
lat: center.lat(),
lng: center.lng(),
map: that,
@ -418,12 +418,10 @@ Ox.Map = function(options, self) {
function addPlaceToPlaces(data) {
var place = getSelectedPlace(),
country = Ox.getCountryByGeoname(place.geoname);
if (self.options.selected == place.id) {
self.options.selected = place.id.substr(1);
}
place.id = place.id.substr(1); // fixme: NOT SAFE!
Ox.extend(place, data);
self.options.selected = place.id;
place.countryCode = country ? country.code : '';
Ox.print('addP2P', data, place);
place.marker.update();
self.places.push(place);
self.resultPlace = null;
@ -822,7 +820,7 @@ Ox.Map = function(options, self) {
editable: self.options.editable,
fullGeoname: getFullGeoname(data.address_components),
geoname: data.formatted_address,
id: '_' + Ox.uid(),
id: '_' + Ox.encodeBase32(Ox.uid()),
map: that,
name: data.formatted_address.split(', ')[0],
north: bounds.getNorthEast().lat(),
@ -949,10 +947,13 @@ Ox.Map = function(options, self) {
select();
});
}
} else {
place = null;
select();
}
}
function select() {
place.select();
place && place.select();
self.options.selected = id;
setStatus();
that.triggerEvent('selectplace', place);