more map
This commit is contained in:
parent
122cc33cb5
commit
9067e96499
2 changed files with 141 additions and 35 deletions
|
@ -1870,6 +1870,14 @@ Geo functions
|
|||
return {lat: lat, lng: lng};
|
||||
};
|
||||
|
||||
Ox.getDegreesPerMeter = function(lat) {
|
||||
/*
|
||||
>>> Ox.EARTH_CIRCUMFERENCE = 360 / Ox.getDegreesPerMeter(0)
|
||||
true
|
||||
*/
|
||||
return 360 / Ox.EARTH_CIRCUMFERENCE / Math.cos(lat * Math.PI / 180);
|
||||
};
|
||||
|
||||
Ox.getDistance = function(point0, point1) {
|
||||
/*
|
||||
>>> Ox.EARTH_CIRCUMFERENCE == Ox.getDistance({lat: -45, lng: -90}, {lat: 45, lng: 90}) * 2
|
||||
|
|
|
@ -8789,11 +8789,11 @@ requires
|
|||
|
||||
if (self.options.data) {
|
||||
self.options.items = [];
|
||||
Ox.print('d', self.options.data, 'i', self.options.items)
|
||||
//Ox.print('d', self.options.data, 'i', self.options.items)
|
||||
Ox.forEach(self.options.data, function(value, key) {
|
||||
self.options.items.push(parseData(key, value));
|
||||
});
|
||||
Ox.print('d', self.options.data, 'i', self.options.items)
|
||||
//Ox.print('d', self.options.data, 'i', self.options.items)
|
||||
}
|
||||
|
||||
that.$element = new Ox.List({
|
||||
|
@ -8885,7 +8885,7 @@ requires
|
|||
}
|
||||
|
||||
function parseData(key, value) {
|
||||
Ox.print('parseData', key, value)
|
||||
//Ox.print('parseData', key, value)
|
||||
var ret = {
|
||||
id: key,
|
||||
title: key.toString().split('.').pop()
|
||||
|
@ -8952,6 +8952,12 @@ requires
|
|||
});
|
||||
}
|
||||
|
||||
self.onChange = function(key, value) {
|
||||
if (key == 'data') {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
@ -9221,7 +9227,7 @@ requires
|
|||
resize: function() {
|
||||
self.$map.resizeMap();
|
||||
},
|
||||
select: selectPlace
|
||||
selectplace: selectPlace
|
||||
});
|
||||
that.$element.replaceWith(
|
||||
that.$element = new Ox.SplitPanel({
|
||||
|
@ -9691,7 +9697,8 @@ requires
|
|||
function parseGeodata(data) {
|
||||
var bounds = data.geometry.bounds || data.geometry.viewport,
|
||||
place = {
|
||||
// countryCode: Ox.getCountryCode(data.formatted_address),
|
||||
components: data.address_components,
|
||||
countryCode: Ox.getCountryCode(data.formatted_address),
|
||||
east: bounds.getNorthEast().lng(),
|
||||
geoname: data.formatted_address,
|
||||
id: '_' + Ox.uid(),
|
||||
|
@ -9699,6 +9706,7 @@ requires
|
|||
name: data.formatted_address.split(', ')[0],
|
||||
north: bounds.getNorthEast().lat(),
|
||||
south: bounds.getSouthWest().lat(),
|
||||
types: data.types,
|
||||
west: bounds.getSouthWest().lng()
|
||||
};
|
||||
return place;
|
||||
|
@ -9754,7 +9762,7 @@ requires
|
|||
self.options.selected = id;
|
||||
self.selected = id;
|
||||
setStatus();
|
||||
that.triggerEvent('select', place);
|
||||
that.triggerEvent('selectplace', place);
|
||||
/*
|
||||
that.triggerEvent('select', {
|
||||
id: self.options.selected
|
||||
|
@ -10257,31 +10265,45 @@ requires
|
|||
Ox.forEach(options, function(val, key) {
|
||||
that[key] = val;
|
||||
});
|
||||
that.points = {
|
||||
ne: new google.maps.LatLng(that.north, that.east),
|
||||
sw: new google.maps.LatLng(that.south, that.west)
|
||||
};
|
||||
that.bounds = new google.maps.LatLngBounds(that.points.sw, that.points.ne);
|
||||
that.center = that.bounds.getCenter();
|
||||
that.lat = that.center.lat();
|
||||
that.lng = that.center.lng();
|
||||
Ox.extend(that.points, {
|
||||
center: that.center,
|
||||
e: new google.maps.LatLng(that.lat, that.east),
|
||||
s: new google.maps.LatLng(that.south, that.lng),
|
||||
se: new google.maps.LatLng(that.south, that.east),
|
||||
n: new google.maps.LatLng(that.north, that.lng),
|
||||
nw: new google.maps.LatLng(that.north, that.west),
|
||||
w: new google.maps.LatLng(that.lat, that.west),
|
||||
});
|
||||
that.marker = new Ox.MapMarker({
|
||||
map: that.map,
|
||||
place: that
|
||||
});
|
||||
that.polygon = new Ox.MapPolygon({
|
||||
map: that.map,
|
||||
place: that
|
||||
});
|
||||
|
||||
update();
|
||||
|
||||
function update() {
|
||||
that.points = {
|
||||
ne: new google.maps.LatLng(that.north, that.east),
|
||||
sw: new google.maps.LatLng(that.south, that.west)
|
||||
};
|
||||
that.bounds = new google.maps.LatLngBounds(that.points.sw, that.points.ne);
|
||||
that.center = that.bounds.getCenter();
|
||||
that.lat = that.center.lat();
|
||||
that.lng = that.center.lng();
|
||||
Ox.extend(that.points, {
|
||||
e: new google.maps.LatLng(that.lat, that.east),
|
||||
s: new google.maps.LatLng(that.south, that.lng),
|
||||
se: new google.maps.LatLng(that.south, that.east),
|
||||
n: new google.maps.LatLng(that.north, that.lng),
|
||||
nw: new google.maps.LatLng(that.north, that.west),
|
||||
w: new google.maps.LatLng(that.lat, that.west),
|
||||
});
|
||||
that.crossesDateline = that.west > that.east;
|
||||
that.sizeNorthSouth = (that.north - that.south) * Ox.EARTH_CIRCUMFERENCE / 360;
|
||||
that.sizeEastWest = Math.abs(that.west - that.east) * Ox.getMetersPerDegree(that.lat);
|
||||
that.size = Ox.getArea(
|
||||
{lat: that.south, lng: that.west},
|
||||
{lat: that.north, lng: that.east}
|
||||
);
|
||||
if (!that.marker) {
|
||||
that.marker = new Ox.MapMarker({
|
||||
map: that.map,
|
||||
place: that
|
||||
});
|
||||
that.polygon = new Ox.MapPolygon({
|
||||
map: that.map,
|
||||
place: that
|
||||
});
|
||||
}
|
||||
Ox.print('PLACE', that)
|
||||
}
|
||||
|
||||
that.add = function() {
|
||||
Ox.print('MapPlace add', that)
|
||||
|
@ -10299,7 +10321,7 @@ requires
|
|||
|
||||
that.edit = function() {
|
||||
that.editing = true;
|
||||
that.marker.update();
|
||||
that.marker.edit();
|
||||
that.polygon.select();
|
||||
return that;
|
||||
}
|
||||
|
@ -10325,6 +10347,10 @@ requires
|
|||
that.marker.update();
|
||||
that.polygon.deselect();
|
||||
return that;
|
||||
};
|
||||
|
||||
that.update = function(str) {
|
||||
update();
|
||||
}
|
||||
|
||||
return that;
|
||||
|
@ -10344,6 +10370,7 @@ requires
|
|||
});
|
||||
that.marker = new google.maps.Marker({
|
||||
position: that.place.center,
|
||||
raiseOnDrag: false,
|
||||
title: that.place.name
|
||||
});
|
||||
|
||||
|
@ -10364,6 +10391,7 @@ requires
|
|||
|
||||
function setOptions() {
|
||||
that.marker.setOptions({
|
||||
draggable: that.place.editing,
|
||||
icon: new google.maps.MarkerImage(
|
||||
oxui.path + 'png/ox.ui/mapMarker' +
|
||||
(that.place.id[0] == '_' ? 'Result' : '') +
|
||||
|
@ -10373,10 +10401,30 @@ requires
|
|||
new google.maps.Size(16, 16),
|
||||
new google.maps.Point(0, 0),
|
||||
new google.maps.Point(8, 8)
|
||||
)
|
||||
),
|
||||
position: that.place.center
|
||||
});
|
||||
}
|
||||
|
||||
function dragstart(e) {
|
||||
}
|
||||
|
||||
function drag(e) {
|
||||
var lat = e.latLng.lat(),
|
||||
lng = e.latLng.lng();
|
||||
Ox.print(lat - that.place.lat)
|
||||
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.update();
|
||||
that.place.polygon.update();
|
||||
}
|
||||
|
||||
function dragend(e) {
|
||||
|
||||
}
|
||||
|
||||
that.add = function() {
|
||||
Ox.print('MapMarker add', that)
|
||||
that.marker.setMap(that.map.map);
|
||||
|
@ -10384,12 +10432,25 @@ requires
|
|||
return that;
|
||||
};
|
||||
|
||||
that.edit = function() {
|
||||
setOptions();
|
||||
google.maps.event.addListener(that.marker, 'dragstart', dragstart);
|
||||
google.maps.event.addListener(that.marker, 'drag', drag);
|
||||
google.maps.event.addListener(that.marker, 'dragend', dragend);
|
||||
};
|
||||
|
||||
that.remove = function() {
|
||||
that.marker.setMap(null);
|
||||
google.maps.event.clearListeners(that.marker);
|
||||
return that;
|
||||
};
|
||||
|
||||
that.submit = function() {
|
||||
google.maps.event.clearListeners(that.marker, 'dragstart');
|
||||
google.maps.event.clearListeners(that.marker, 'drag');
|
||||
google.maps.event.clearListeners(that.marker, 'dragend');
|
||||
}
|
||||
|
||||
that.update = function() {
|
||||
setOptions();
|
||||
}
|
||||
|
@ -10440,7 +10501,6 @@ requires
|
|||
} else {
|
||||
that.map.panToPlace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setOptions() {
|
||||
|
@ -10480,6 +10540,21 @@ requires
|
|||
});
|
||||
};
|
||||
|
||||
that.update = function() {
|
||||
that.polygon.setOptions({
|
||||
paths: [
|
||||
that.place.points.sw,
|
||||
that.place.points.nw,
|
||||
that.place.points.ne,
|
||||
that.place.points.se,
|
||||
that.place.points.sw
|
||||
]
|
||||
});
|
||||
Ox.forEach(that.markers, function(marker) {
|
||||
marker.update();
|
||||
});
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
@ -10516,7 +10591,24 @@ requires
|
|||
}
|
||||
|
||||
function drag(e) {
|
||||
|
||||
var lat = e.latLng.lat(),
|
||||
lng = e.latLng.lng(),
|
||||
degreesPerMeter = Ox.getDegreesPerMeter(that.place.lat);
|
||||
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);
|
||||
}
|
||||
if (that.position.indexOf('n') > -1) {
|
||||
that.place.north = Math.max(lat, that.place.south + degreesPerMeter);
|
||||
}
|
||||
if (that.position.indexOf('e') > -1) {
|
||||
that.place.east = Math.max(lng, that.place.west + degreesPerMeter)
|
||||
}
|
||||
that.place.update();
|
||||
that.place.marker.update();
|
||||
that.place.polygon.update();
|
||||
}
|
||||
|
||||
function dragend(e) {
|
||||
|
@ -10535,6 +10627,12 @@ requires
|
|||
google.maps.event.clearListeners(that.marker);
|
||||
};
|
||||
|
||||
that.update = function() {
|
||||
that.marker.setOptions({
|
||||
position: that.place.points[that.position]
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue