forked from 0x2620/oxjs
update map and calendar
This commit is contained in:
parent
f61e39a788
commit
30088ad0b1
5 changed files with 73 additions and 96 deletions
|
|
@ -186,12 +186,14 @@ Ox.Map = function(options, self) {
|
|||
|
||||
self.isAsync = Ox.isFunction(self.options.places);
|
||||
self.mapHeight = getMapHeight();
|
||||
self.metaKey = false;
|
||||
self.minZoom = getMinZoom();
|
||||
self.placeKeys = [
|
||||
'id', 'name', 'alternativeNames', 'geoname', 'countryCode', 'type',
|
||||
'lat', 'lng', 'south', 'west', 'north', 'east', 'area',
|
||||
'editable'
|
||||
];
|
||||
self.resultPlace = null;
|
||||
self.scaleMeters = [
|
||||
50000000, 20000000, 10000000,
|
||||
5000000, 2000000, 1000000,
|
||||
|
|
@ -201,12 +203,7 @@ Ox.Map = function(options, self) {
|
|||
500, 200, 100,
|
||||
50, 20, 10
|
||||
];
|
||||
|
||||
Ox.extend(self, {
|
||||
metaKey: false,
|
||||
resultPlace: null,
|
||||
shiftKey: false
|
||||
});
|
||||
self.shiftKey = false;
|
||||
|
||||
if (self.options.toolbar) {
|
||||
self.$toolbar = Ox.Bar({
|
||||
|
|
@ -513,7 +510,6 @@ Ox.Map = function(options, self) {
|
|||
self.places.push(place);
|
||||
self.resultPlace = null;
|
||||
that.triggerEvent('addplace', place)
|
||||
//Ox.Log('Map', 'SSSS', self.options.selected)
|
||||
}
|
||||
|
||||
function boundsChanged() {
|
||||
|
|
@ -570,7 +566,6 @@ Ox.Map = function(options, self) {
|
|||
}
|
||||
|
||||
function constructZoomInput() {
|
||||
//Ox.Log('Map', 'constructZoomInput', self.minZoom, self.maxZoom)
|
||||
if (self.options.zoombar) {
|
||||
self.$zoomInput && self.$zoomInput.remove();
|
||||
self.$zoomInput = Ox.Range({
|
||||
|
|
@ -676,17 +671,13 @@ Ox.Map = function(options, self) {
|
|||
}
|
||||
|
||||
function getPlaceById(id) {
|
||||
var place = Ox.getObjectById(self.places, id);
|
||||
if (!place && self.resultPlace && self.resultPlace.id == id) {
|
||||
place = self.resultPlace;
|
||||
}
|
||||
//Ox.Log('Map', 'getPlaceById', id, place)
|
||||
return place;
|
||||
return self.resultPlace && self.resultPlace.id == id
|
||||
? self.resultPlace
|
||||
: Ox.getObjectById(self.places, id);
|
||||
}
|
||||
|
||||
function getPlaceByLatLng(latlng, bounds, callback) {
|
||||
// gets the largest place at latlng that would fit in bounds
|
||||
//Ox.Log('Map', 'll b', latlng, bounds)
|
||||
var callback = arguments.length == 3 ? callback : bounds,
|
||||
bounds = arguments.length == 3 ? bounds : null;
|
||||
self.geocoder.geocode({
|
||||
|
|
@ -775,8 +766,9 @@ Ox.Map = function(options, self) {
|
|||
}
|
||||
|
||||
function getSelectedPlace() {
|
||||
return self.options.selected ?
|
||||
getPlaceById(self.options.selected) : null;
|
||||
return self.options.selected
|
||||
? getPlaceById(self.options.selected)
|
||||
: null;
|
||||
}
|
||||
|
||||
function initMap() {
|
||||
|
|
@ -903,9 +895,11 @@ Ox.Map = function(options, self) {
|
|||
self.places.sort(function(a, b) {
|
||||
var sort = {
|
||||
a: a.selected ? Infinity
|
||||
: bounds.contains(a.center) ? a.area : -Infinity,
|
||||
: bounds.contains(a.center) ? a.area
|
||||
: -Infinity,
|
||||
b: b.selected ? Infinity
|
||||
: bounds.contains(b.center) ? b.area : -Infinity,
|
||||
: bounds.contains(b.center) ? b.area
|
||||
: -Infinity,
|
||||
};
|
||||
return sort.b - sort.a;
|
||||
}).forEach(function(place, i) {
|
||||
|
|
@ -1052,6 +1046,14 @@ Ox.Map = function(options, self) {
|
|||
]
|
||||
},
|
||||
type = 'feature';
|
||||
function find(type) {
|
||||
var ret;
|
||||
Ox.forEach(types, function(v) {
|
||||
ret = Ox.startsWith(v, type);
|
||||
return !ret;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
Ox.forEach(strings, function(values, key) {
|
||||
Ox.forEach(values, function(value) {
|
||||
if (find(value)) {
|
||||
|
|
@ -1062,14 +1064,6 @@ Ox.Map = function(options, self) {
|
|||
return type == 'feature';
|
||||
});
|
||||
return type;
|
||||
function find(type) {
|
||||
var ret;
|
||||
Ox.forEach(types, function(v) {
|
||||
ret = Ox.startsWith(v, type);
|
||||
return !ret;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return place;
|
||||
}
|
||||
|
|
@ -1105,7 +1099,6 @@ Ox.Map = function(options, self) {
|
|||
var place = getSelectedPlace();
|
||||
place.id = '_' + place.id;
|
||||
self.options.selected = place.id;
|
||||
//Ox.Log('Map', 'removePlace', Ox.getObjectById(self.places, place.id))
|
||||
self.places.splice(Ox.getIndexById(self.places, place.id), 1);
|
||||
self.resultPlace && self.resultPlace.remove();
|
||||
self.resultPlace = place;
|
||||
|
|
@ -1113,31 +1106,11 @@ Ox.Map = function(options, self) {
|
|||
}
|
||||
|
||||
function reset() {
|
||||
//Ox.Log('Map', self.map.getZoom(), self.zoom);
|
||||
self.map.getZoom() == self.zoom ?
|
||||
self.map.panTo(self.center) :
|
||||
self.map.fitBounds(self.bounds);
|
||||
self.map.getZoom() == self.zoom
|
||||
? self.map.panTo(self.center)
|
||||
: self.map.fitBounds(self.bounds);
|
||||
}
|
||||
|
||||
function resizeMap() {
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
}
|
||||
|
||||
function selectPlace(id, zoom) {
|
||||
// id can be null (deselect)
|
||||
var place,
|
||||
|
|
@ -1404,13 +1377,9 @@ Ox.Map = function(options, self) {
|
|||
};
|
||||
|
||||
that.getKey = function() {
|
||||
var key = null;
|
||||
if (self.shiftKey) {
|
||||
key = 'shift'
|
||||
} else if (self.metaKey) {
|
||||
key = 'meta'
|
||||
}
|
||||
return key;
|
||||
return self.shiftKey ? 'shift'
|
||||
: self.metaKey ? 'meta'
|
||||
: null;
|
||||
};
|
||||
|
||||
that.getSelectedPlace = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue