From 8851a9c454bf24ff098c7f9bfbcf207a721df96f Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Tue, 21 Feb 2012 09:37:50 +0000 Subject: [PATCH] in manage places, make south/west/north/east editable directly (fixes #411) --- source/Ox.UI/js/Map/Ox.ListMap.js | 8 +++-- source/Ox.UI/js/Map/Ox.Map.js | 55 +++++------------------------ source/Ox.UI/js/Map/Ox.MapMarker.js | 2 +- 3 files changed, 15 insertions(+), 50 deletions(-) diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index 5f5386c4..c7f9ec81 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -509,6 +509,7 @@ Ox.ListMap = function(options, self) { ).toLowerCase(), max = ['Latitude', 'South', 'North'].indexOf(v) > -1 ? Ox.MAX_LATITUDE : 180; return Ox.Input({ + changeOnKeypress: true, decimals: 8, disabled: ['lat', 'lng'].indexOf(id) > -1, id: id, @@ -532,6 +533,7 @@ Ox.ListMap = function(options, self) { .hide() .bindEvent({ change: function(data) { + Ox.print('CHANGE', data) var isResult = self.selectedPlace[0] == '_'; if (data.id == 'name') { !isResult && self.$list.value(self.selectedPlace, 'name', data.data.value); @@ -573,14 +575,14 @@ Ox.ListMap = function(options, self) { if (!self.isAsync) { // ... } else { - !isResult && editPlace(['type']) + !isResult && editPlace(['type']); } self.$map.value(self.selectedPlace, 'type', data.data.value); - } else { // lat, lng, south, west, north, east + } else { // south, west, north, east if (!self.isAsync) { // ... } else { - !isResult && editPlace([data.id]) + !isResult && editPlace([data.id]); } self.$map.value(self.selectedPlace, data.id, parseFloat(data.data.value)); } diff --git a/source/Ox.UI/js/Map/Ox.Map.js b/source/Ox.UI/js/Map/Ox.Map.js index fff41a80..9b39ebfc 100644 --- a/source/Ox.UI/js/Map/Ox.Map.js +++ b/source/Ox.UI/js/Map/Ox.Map.js @@ -1448,14 +1448,6 @@ Ox.Map = function(options, self) { return that; }; - /* - that.editPlace = function(data) { - var place = getPlaceById(self.options.selected); - place.$marker.options(data); - return that; - }; - */ - that.findPlace = function(name, callback) { getPlaceByName(name, function(place) { if (place) { @@ -1466,10 +1458,12 @@ Ox.Map = function(options, self) { } callback(place); }); + return that; }; that.newPlace = function(place) { addPlaceToMap(place); + return that; }; that.panToPlace = function() { @@ -1484,41 +1478,8 @@ Ox.Map = function(options, self) { }; that.resizeMap = function() { - - /* - Ox.Log('Map', 'resizeMap', self.options.width, self.options.height); - var center = self.map.getCenter(); - self.mapHeight = getMapHeight(); - self.minZoom = getMinZoom(); - that.css({ - height: self.options.height + 'px', - width: self.options.width + 'px' - }); - self.$map.css({ - height: self.mapHeight + 'px', - width: self.options.width + 'px' - }); - google.maps.event.trigger(self.map, 'resize'); - self.map.setCenter(center); - */ - - /* - Ox.Log('Map', 'Ox.Map.resizeMap()'); - var center = self.map.getCenter(); - self.options.height = that.$element.height(); - self.options.width = that.$element.width(); - Ox.Log('Map', self.options.width, self.options.height) - self.$map.css({ - height: self.mapHeight + 'px', - width: self.options.width + 'px' - }); - google.maps.event.trigger(self.map, 'resize'); - self.map.setCenter(center); - self.options.zoombar && self.$zoomInput.options({ - size: self.options.width - }); - */ - + // keep center on resize has been commented out + // var center = self.map.getCenter(); self.options.height = that.$element.height(); self.options.width = that.$element.width(); // check if map has initialized @@ -1536,15 +1497,17 @@ Ox.Map = function(options, self) { size: self.options.width }); updateFormElements(); - Ox.print('triggering google maps resize event, height', self.options.height) + Ox.Log('Map', 'triggering google maps resize event, height', self.options.height) google.maps.event.trigger(self.map, 'resize'); + // self.map.setCenter(center); } return that; } that.value = function(id, key, value) { // fixme: should be like the corresponding List/TextList/etc value function - Ox.print('Map', 'Map.value', id, key, value) + Ox.print('Map', 'Map.value', id, key, value); + getPlaceById(id).options(key, value); if (id == self.options.selected) { if (key == 'name') { self.$placeControls.name.options({title: value}); @@ -1556,7 +1519,7 @@ Ox.Map = function(options, self) { ); } } - getPlaceById(id).options(key, value); + return that; } that.zoomToPlace = function() { diff --git a/source/Ox.UI/js/Map/Ox.MapMarker.js b/source/Ox.UI/js/Map/Ox.MapMarker.js index d14633a5..a322e50b 100644 --- a/source/Ox.UI/js/Map/Ox.MapMarker.js +++ b/source/Ox.UI/js/Map/Ox.MapMarker.js @@ -125,7 +125,7 @@ Ox.MapMarker = function(options) { that.place.update(); that.marker.setOptions({ position: that.place.center - }) + }); that.place.rectangle.update(); }