From e815b2f2e1a4ac06dc9914fb635adc547037bcd2 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sat, 5 Mar 2011 13:03:45 +0000 Subject: [PATCH] keep rectangles from growing too wide when moved towards the poles --- build/js/ox.ui.js | 48 ++++++----------------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 5ccf3936..cb32252a 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -10077,45 +10077,6 @@ requires } } - function Rectangle(area) { // fixme: not used - var latlng = { - sw: new google.maps.LatLng(area[0][0], area[0][1]), - ne: new google.maps.LatLng(area[1][0], area[1][1]) - }, - bounds = new google.maps.LatLngBounds(latlng.sw, latlng.ne), - lat = {}, - lng = {}; - latlng.mc = bounds.getCenter(); - $.each(latlng, function(k, v) { - lat[k] = v.lat(); - lng[k] = v.lng(); - }); - $.extend(latlng, { - sc: new google.maps.LatLng(lat.sw, lng.mc), - se: new google.maps.LatLng(lat.sw, lng.ne), - mw: new google.maps.LatLng(lat.mc, lng.sw), - me: new google.maps.LatLng(lat.mc, lng.ne), - nw: new google.maps.LatLng(lat.ne, lng.sw), - nc: new google.maps.LatLng(lat.ne, lng.mc), - }); - return { - area: area, - bounds: bounds, - canContain: function(rectangle) { - var outerSpan = this.bounds.toSpan(), - innerSpan = rectangle.bounds.toSpan(); - return outerSpan.lat() > innerSpan.lat() && - outerSpan.lng() > innerSpan.lng(); - }, - center: latlng.mc, - contains: function(rectangle) { - return this.bounds.contains(rectangle.bounds.getSouthWest()) && - this.bounds.contains(rectangle.bounds.getNorthEast()); - }, - latlng: latlng - }; - } - self.onChange = function(key, value) { if (key == 'height' || key == 'width') { resizeMap(); @@ -10412,17 +10373,20 @@ requires Ox.MAX_LATITUDE - northSouth ), lng = e.latLng.lng(), + span = Math.min( + that.place.sizeEastWest * Ox.getDegreesPerMeter(lat) / 2, 179.99999999 + ); degreesPerMeter = Ox.getDegreesPerMeter(lat); that.place.south += lat - that.place.lat; that.place.north += lat - that.place.lat; - that.place.west = lng - that.place.sizeEastWest * degreesPerMeter / 2; - that.place.east = lng + that.place.sizeEastWest * degreesPerMeter / 2; + that.place.west = lng - span; + that.place.east = lng + span; if (that.place.west < -180) { that.place.west += 360; } else if (that.place.east > 180) { that.place.east -= 360; } - Ox.print('west', that.place.west, 'east', that.place.east); + Ox.print('west', that.place.west, 'east', that.place.east, 'span', span); that.place.update(); that.marker.setOptions({ position: that.place.center