Ox.Map: meta+click on selected place now deselects it (fixes #655)

This commit is contained in:
rlx 2012-04-23 10:28:42 +00:00
parent c0c4031825
commit fa146ebbba
3 changed files with 24 additions and 11 deletions

View file

@ -23,7 +23,8 @@ Ox.Keyboard = (function() {
Ox.forEach(Ox.MODIFIER_KEYS, function(v, k) {
// avoid pushing modifier twice
// using event.originalEvent since jquery always sets event.metaKey to event.ctrlKey
// using event.originalEvent since jquery always sets
// event.metaKey to event.ctrlKey
if (event.originalEvent[k] && keyBasename != v) {
keyNames.splice(-1, 0, v);
}

View file

@ -142,7 +142,16 @@ Ox.Map = function(options, self) {
key_left: function() {
pan(-1, 0);
},
key_meta: function() {
// FIXME:
'key_meta.left': function() {
self.metaKey = true;
$(document).one({
keyup: function() {
self.metaKey = false;
}
});
},
'key_meta.right': function() {
self.metaKey = true;
$(document).one({
keyup: function() {

View file

@ -52,14 +52,17 @@ Ox.MapMarker = function(options) {
setOptions();
function click() {
var key = that.map.getKey(),
place, bounds, southWest, northEast;
if (!that.place.selected) {
if (that.map.getKey() == 'shift') {
var place = that.map.getSelectedPlace(),
if (key == 'meta' || key == 'shift') {
place = that.map.getSelectedPlace();
}
if (place) {
bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(place.south, place.west),
new google.maps.LatLng(place.north, place.east)
),
southWest, northEast;
);
bounds = bounds.union(that.place.bounds);
southWest = bounds.getSouthWest();
northEast = bounds.getNorthEast();
@ -82,7 +85,7 @@ Ox.MapMarker = function(options) {
that.map.options({selected: that.place.id});
}
} else {
if (that.map.getKey() == 'meta') {
if (key == 'meta') {
that.map.options({selected: null});
} else {
that.map.panToPlace();