fix getting wrong coordinates for places in list

This commit is contained in:
Sanjay Bhangar 2025-08-09 17:23:30 +02:00
commit 411cfed6cc
4 changed files with 7 additions and 18 deletions

View file

@ -123,13 +123,9 @@ Ox.Map = function(options, self) {
that.resizeMap();
},
places: function() {
console.log('MAP OPTIONS.PLACES UPDATE - Processing places array, count:', self.options.places ? self.options.places.length : 0);
console.trace('MAP OPTIONS.PLACES UPDATE - Stack trace');
// Prevent rebuilding places while editing to avoid breaking references
var editingPlace = getSelectedPlace();
if (editingPlace && editingPlace.editing) {
console.log('MAP OPTIONS.PLACES UPDATE - Skipping rebuild because place is being edited:', editingPlace.id);
return;
}
@ -258,8 +254,6 @@ Ox.Map = function(options, self) {
});
//FIXME: duplicated in update
console.log('MAP INIT - Processing places array (duplicated code), count:', self.options.places ? self.options.places.length : 0);
console.trace('MAP INIT - Stack trace');
if (Ox.isArray(self.options.places)) {
self.options.places.forEach(function(place) {
if (Ox.isUndefined(place.id)) {
@ -1741,7 +1735,7 @@ Ox.Map = function(options, self) {
Ox.Log('Map', 'Map.value', id, key, value);
var place = getPlaceById(id);
if (!place) {
console.error('Map.value - place not found for id:', id, 'Available places:', Object.keys(self.options.places || {}));
console.error('Map.value - place not found for id:', id);
return;
}
place.options(key, value);

View file

@ -306,9 +306,7 @@ Ox.MapMarker = function(options) {
() -> <f> edit marker, returns MapMarker
@*/
that.edit = function() {
console.log('MAPMARKER.EDIT - before setOptions, marker on map?', that.marker._map !== null);
setOptions();
console.log('MAPMARKER.EDIT - after setOptions, marker on map?', that.marker._map !== null);
that.marker.on('dragstart', dragstart);
that.marker.on('drag', drag);
that.marker.on('dragend', dragend);

View file

@ -39,7 +39,12 @@ Ox.MapPlace = function(options) {
var that = this;
Ox.forEach(options, function(val, key) {
that[key] = val;
// Ensure coordinate values are independent copies, not shared references
if (key === 'south' || key === 'north' || key === 'east' || key === 'west') {
that[key] = parseFloat(val) || 0;
} else {
that[key] = val;
}
});
// Ensure editable is set for existing places that might not have this property
@ -47,7 +52,6 @@ Ox.MapPlace = function(options) {
that.editable = true;
}
console.log('MAPPLACE CONSTRUCTOR - Creating place with ID:', that.id, 'name:', that.name);
update();

View file

@ -225,18 +225,11 @@ Ox.MapRectangle = function(options) {
setOptions();
function click(e) {
console.log('RECTANGLE CLICK DEBUG:');
console.log('- map.editable:', that.map.options('editable'));
console.log('- place.editable:', that.place.editable);
console.log('- place.editing:', that.place.editing);
console.log('- place object:', that.place);
if (
that.map.options('editable')
&& that.place.editable
&& !that.place.editing
) {
console.log('- Calling place.edit()');
that.place.edit();
} else if (that.map.getKey() == 'meta') {
that.place.submit();