Commit 14cf95e9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

click listeners return x,y coordinates

parent b9aa2633
......@@ -45,30 +45,38 @@
"litemol": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412"
},
"dependencies": {
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
}
}
},
"jquery": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
"dev": true
}
}
},
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
},
"litemol": {
"version": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412",
"dev": true,
"requires": {
"@types/react": "15.6.15",
"@types/react-dom": "15.5.7"
}
}
}
},
......@@ -2050,14 +2058,6 @@
"immediate": "3.0.6"
}
},
"litemol": {
"version": "github:dsehnal/LiteMol#67556b0de0d2428f9494136758cbf8a662f66412",
"dev": true,
"requires": {
"@types/react": "15.6.15",
"@types/react-dom": "15.5.7"
}
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
......
......@@ -150,32 +150,30 @@ AbstractCustomMap.prototype.registerMapClickEvents = function () {
var self = this;
// search event
this.getMapCanvas().addListener('click', function (mouseEvent) {
var point = self.fromLatLngToPoint(mouseEvent.latLng);
this.getMapCanvas().addListener('click', function (event) {
var searchDb = customMap.getOverlayByName('search');
if (searchDb !== undefined) {
return searchDb.searchByCoordinates({
modelId: self.getModel().getId(),
coordinates: point,
coordinates: event.arg.point,
zoom: self.getGoogleMap().getZoom()
}).then(null, GuiConnector.alert);
}).catch(GuiConnector.alert);
} else {
logger.warn("Search is impossible because search db is not present");
}
});
// select last clicked map
this.getMapCanvas().addListener('click', function (mouseEvent) {
this.getMapCanvas().addListener('click', function (event) {
customMap.setActiveSubmapId(self.getId());
customMap.setActiveSubmapClickCoordinates(self.fromLatLngToPoint(mouseEvent.latLng));
customMap.setActiveSubmapClickCoordinates(event.arg.point);
});
// select last clicked map
this.getMapCanvas().addListener('rightclick', function (mouseEvent) {
this.getMapCanvas().addListener('rightclick', function (event) {
customMap.setActiveSubmapId(self.getId());
var coordinates = self.fromLatLngToPoint(mouseEvent.latLng);
customMap.setActiveSubmapClickCoordinates(coordinates);
return activateMolStarLink(coordinates, self);
customMap.setActiveSubmapClickCoordinates(event.arg.point);
return activateMolStarLink(event.arg.point, self);
});
// prepare for image export
......@@ -859,6 +857,10 @@ AbstractCustomMap.prototype.getSelectedLayoutOverlays = function () {
return this.selectedLayoutOverlays;
};
/**
*
* @returns {MapCanvas}
*/
AbstractCustomMap.prototype.getMapCanvas = function () {
return this._canvas;
};
......
......@@ -222,7 +222,18 @@ GoogleMapsApiCanvas.prototype.createInfoWindow = function (options) {
};
GoogleMapsApiCanvas.prototype.addListener = function (type, callback) {
google.maps.event.addListener(this.getGoogleMap(), type, callback);
var self = this;
var wrapper = callback;
if (type === "click") {
wrapper = function (e) {
return callback({arg: {point: self.fromLatLngToPoint(e.latLng)}});
}
} else if (type === "rightclick") {
wrapper = function (e) {
return callback({arg: {point: self.fromLatLngToPoint(e.latLng)}});
}
}
google.maps.event.addListener(this.getGoogleMap(), type, wrapper);
};
GoogleMapsApiCanvas.prototype.addLeftBottomControl = function (element) {
......@@ -261,15 +272,13 @@ GoogleMapsApiCanvas.prototype.getCenter = function () {
GoogleMapsApiCanvas.prototype.getZoom = function () {
return this.getGoogleMap().getZoom();
};
GoogleMapsApiCanvas.prototype.getBackgroundId= function () {
GoogleMapsApiCanvas.prototype.getBackgroundId = function () {
return this.getGoogleMap().getMapTypeId();
};
GoogleMapsApiCanvas.prototype.setBackgroundId= function (backgroundId) {
GoogleMapsApiCanvas.prototype.setBackgroundId = function (backgroundId) {
this.getGoogleMap().setMapTypeId(backgroundId.toString());
};
module.exports = GoogleMapsApiCanvas;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment