keep rectangles from growing too wide when moved towards the poles
This commit is contained in:
parent
311521c911
commit
e815b2f2e1
1 changed files with 6 additions and 42 deletions
|
@ -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) {
|
self.onChange = function(key, value) {
|
||||||
if (key == 'height' || key == 'width') {
|
if (key == 'height' || key == 'width') {
|
||||||
resizeMap();
|
resizeMap();
|
||||||
|
@ -10412,17 +10373,20 @@ requires
|
||||||
Ox.MAX_LATITUDE - northSouth
|
Ox.MAX_LATITUDE - northSouth
|
||||||
),
|
),
|
||||||
lng = e.latLng.lng(),
|
lng = e.latLng.lng(),
|
||||||
|
span = Math.min(
|
||||||
|
that.place.sizeEastWest * Ox.getDegreesPerMeter(lat) / 2, 179.99999999
|
||||||
|
);
|
||||||
degreesPerMeter = Ox.getDegreesPerMeter(lat);
|
degreesPerMeter = Ox.getDegreesPerMeter(lat);
|
||||||
that.place.south += lat - that.place.lat;
|
that.place.south += lat - that.place.lat;
|
||||||
that.place.north += lat - that.place.lat;
|
that.place.north += lat - that.place.lat;
|
||||||
that.place.west = lng - that.place.sizeEastWest * degreesPerMeter / 2;
|
that.place.west = lng - span;
|
||||||
that.place.east = lng + that.place.sizeEastWest * degreesPerMeter / 2;
|
that.place.east = lng + span;
|
||||||
if (that.place.west < -180) {
|
if (that.place.west < -180) {
|
||||||
that.place.west += 360;
|
that.place.west += 360;
|
||||||
} else if (that.place.east > 180) {
|
} else if (that.place.east > 180) {
|
||||||
that.place.east -= 360;
|
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.place.update();
|
||||||
that.marker.setOptions({
|
that.marker.setOptions({
|
||||||
position: that.place.center
|
position: that.place.center
|
||||||
|
|
Loading…
Reference in a new issue