Ox.Map: meta+click on selected place now deselects it (fixes #655)
This commit is contained in:
parent
c0c4031825
commit
fa146ebbba
3 changed files with 24 additions and 11 deletions
|
@ -23,7 +23,8 @@ Ox.Keyboard = (function() {
|
||||||
|
|
||||||
Ox.forEach(Ox.MODIFIER_KEYS, function(v, k) {
|
Ox.forEach(Ox.MODIFIER_KEYS, function(v, k) {
|
||||||
// avoid pushing modifier twice
|
// 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) {
|
if (event.originalEvent[k] && keyBasename != v) {
|
||||||
keyNames.splice(-1, 0, v);
|
keyNames.splice(-1, 0, v);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,16 @@ Ox.Map = function(options, self) {
|
||||||
key_left: function() {
|
key_left: function() {
|
||||||
pan(-1, 0);
|
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;
|
self.metaKey = true;
|
||||||
$(document).one({
|
$(document).one({
|
||||||
keyup: function() {
|
keyup: function() {
|
||||||
|
|
|
@ -52,14 +52,17 @@ Ox.MapMarker = function(options) {
|
||||||
setOptions();
|
setOptions();
|
||||||
|
|
||||||
function click() {
|
function click() {
|
||||||
|
var key = that.map.getKey(),
|
||||||
|
place, bounds, southWest, northEast;
|
||||||
if (!that.place.selected) {
|
if (!that.place.selected) {
|
||||||
if (that.map.getKey() == 'shift') {
|
if (key == 'meta' || key == 'shift') {
|
||||||
var place = that.map.getSelectedPlace(),
|
place = that.map.getSelectedPlace();
|
||||||
bounds = new google.maps.LatLngBounds(
|
}
|
||||||
new google.maps.LatLng(place.south, place.west),
|
if (place) {
|
||||||
new google.maps.LatLng(place.north, place.east)
|
bounds = new google.maps.LatLngBounds(
|
||||||
),
|
new google.maps.LatLng(place.south, place.west),
|
||||||
southWest, northEast;
|
new google.maps.LatLng(place.north, place.east)
|
||||||
|
);
|
||||||
bounds = bounds.union(that.place.bounds);
|
bounds = bounds.union(that.place.bounds);
|
||||||
southWest = bounds.getSouthWest();
|
southWest = bounds.getSouthWest();
|
||||||
northEast = bounds.getNorthEast();
|
northEast = bounds.getNorthEast();
|
||||||
|
@ -77,12 +80,12 @@ Ox.MapMarker = function(options) {
|
||||||
west: southWest.lng(),
|
west: southWest.lng(),
|
||||||
north: northEast.lat(),
|
north: northEast.lat(),
|
||||||
east: northEast.lng()
|
east: northEast.lng()
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
that.map.options({selected: that.place.id});
|
that.map.options({selected: that.place.id});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (that.map.getKey() == 'meta') {
|
if (key == 'meta') {
|
||||||
that.map.options({selected: null});
|
that.map.options({selected: null});
|
||||||
} else {
|
} else {
|
||||||
that.map.panToPlace();
|
that.map.panToPlace();
|
||||||
|
|
Loading…
Reference in a new issue