From 5d644badd419448dd55ecd826f3d5badc8cbbef1 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 4 Mar 2011 19:07:41 +0000 Subject: [PATCH] more map --- build/js/ox.js | 5 ++-- build/js/ox.ui.js | 68 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/build/js/ox.js b/build/js/ox.js index 5f6690c0..eb780cb7 100644 --- a/build/js/ox.js +++ b/build/js/ox.js @@ -59,8 +59,6 @@ Ox.KEYS = { ';': 186, '=': 187, ',': 188, '-': 189, '.': 190, '/': 191, '`': 192, '(': 219, '\\': 220, ')': 221, '\'': 222 }; -//Ox.MAX_LATITUDE = Ox.deg(Math.atan(Ox.sinh(Math.PI))); -//Ox.MIN_LATITUDE = -Ox.MAX_LATITUDE; Ox.MONTHS = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' @@ -2281,6 +2279,9 @@ Ox.sinh = function(x) { return (Math.exp(x) - Math.exp(-x)) / 2; }; +Ox.MAX_LATITUDE = Ox.deg(Math.atan(Ox.sinh(Math.PI))); +Ox.MIN_LATITUDE = -Ox.MAX_LATITUDE; + /* ================================================================================ RegExp functions diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index fe720ca6..fd4a9eb6 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -10416,6 +10416,7 @@ requires function setOptions() { that.marker.setOptions({ + cursor: that.place.editing ? 'move' : 'pointer', draggable: that.place.editing, icon: new google.maps.MarkerImage( oxui.path + 'png/ox.ui/mapMarker' + @@ -10432,22 +10433,38 @@ requires } function dragstart(e) { + } function drag(e) { - var lat = e.latLng.lat(), - lng = e.latLng.lng(); - Ox.print(lat - that.place.lat) + var northSouth = (that.place.north - that.place.south) / 2, + lat = Ox.limit( + e.latLng.lat(), + Ox.MIN_LATITUDE + northSouth, + Ox.MAX_LATITUDE - northSouth + ), + lng = e.latLng.lng(), + crossesDateline, + degreesPerMeter = Ox.getDegreesPerMeter(lat); + Ox.print('west', that.place.west, 'east', that.place.east); that.place.south += lat - that.place.lat; that.place.north += lat - that.place.lat; - that.place.west = lng - that.place.sizeEastWest * Ox.getDegreesPerMeter(lat) / 2; - that.place.east = lng + that.place.sizeEastWest * Ox.getDegreesPerMeter(lat) / 2; + that.place.west = lng - that.place.sizeEastWest * degreesPerMeter / 2; + that.place.east = lng + that.place.sizeEastWest * degreesPerMeter / 2; + Ox.print('west', that.place.west, 'east', that.place.east); + crossesDateline = that.place.west > that.place.east; + if (that.place.crossesDateline != crossesDateline) { + + } that.place.update(); + that.marker.setOptions({ + position: that.place.center + }) that.place.polygon.update(); } function dragend(e) { - + } that.add = function() { @@ -10612,24 +10629,37 @@ requires }); function dragstart(e) { - + that.drag = { + lat: e.latLng.lat(), + lng: e.latLng.lng() + }; } function drag(e) { - var lat = e.latLng.lat(), + var lat = Ox.limit(e.latLng.lat(), Ox.MIN_LATITUDE, Ox.MAX_LATITUDE), lng = e.latLng.lng(), + crossesDateline = Math.abs(lng - that.drag.lng) > 180, degreesPerMeter = Ox.getDegreesPerMeter(that.place.lat); + that.drag = { + lat: lat, + lng: lng + }; + Ox.print('e', e) if (that.position.indexOf('s') > -1) { - that.place.south = Math.min(lat, that.place.north - degreesPerMeter); - } - if (that.position.indexOf('w') > -1) { - that.place.west = Math.min(lng, that.place.east - degreesPerMeter); + that.place.south = lat; + //Math.min(lat, that.place.north - degreesPerMeter); } if (that.position.indexOf('n') > -1) { - that.place.north = Math.max(lat, that.place.south + degreesPerMeter); + that.place.north = lat; + //Math.max(lat, that.place.south + degreesPerMeter); + } + if (that.position.indexOf('w') > -1) { + that.place.west = lng; + // Math.min(lng, that.place.east - degreesPerMeter); } if (that.position.indexOf('e') > -1) { - that.place.east = Math.max(lng, that.place.west + degreesPerMeter) + that.place.east = lng; + // Math.max(lng, that.place.west + degreesPerMeter) } that.place.update(); that.place.marker.update(); @@ -10637,7 +10667,15 @@ requires } function dragend(e) { - + var south; + if (that.place.south > that.place.north) { + south = that.place.south; + that.place.south = that.place.north; + that.place.north = south; + that.place.update(); + that.place.marker.update(); + that.place.polygon.update(); + } } that.add = function() {