Skip to content
Snippets Groups Projects
Commit ffc43abc authored by Piotr Gawron's avatar Piotr Gawron
Browse files

getcenter method implemented

parent 7f3f12a9
No related branches found
No related tags found
1 merge request!221Resolve "plugin API should allow to store user data"
...@@ -1069,6 +1069,11 @@ AbstractCustomMap.prototype.setCenter = function (coordinates) { ...@@ -1069,6 +1069,11 @@ AbstractCustomMap.prototype.setCenter = function (coordinates) {
} }
}; };
AbstractCustomMap.prototype.getCenter = function () {
var coordinates = this.getGoogleMap().getCenter();
return this.fromLatLngToPoint(coordinates);
};
/** /**
* Sets zoom level for google maps. * Sets zoom level for google maps.
* *
......
...@@ -402,6 +402,13 @@ function createProjectMap(options) { ...@@ -402,6 +402,13 @@ function createProjectMap(options) {
} }
return submap.setCenter(new google.maps.Point(params.x, params.y)); return submap.setCenter(new google.maps.Point(params.x, params.y));
}, },
getCenter: function (params) {
var submap = map.getSubmapById(params.modelId);
if (submap === null) {
throw new Error("Unknown modelId: " + params.modelId);
}
return submap.getCenter();
},
fitBounds: function (params) { fitBounds: function (params) {
var submap = map.getSubmapById(params.modelId); var submap = map.getSubmapById(params.modelId);
if (submap === null) { if (submap === null) {
......
...@@ -310,6 +310,26 @@ describe('MinervaPluginProxy', function () { ...@@ -310,6 +310,26 @@ describe('MinervaPluginProxy', function () {
}); });
}); });
it("getCenter", function () {
var map, proxy;
return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project);
proxy = createProxy(map);
return proxy.project.map.setCenter({
modelId: 15781,
x: 10,
y: 20
});
}).then(function () {
var center = proxy.project.map.getCenter({modelId: 15781});
assert.ok(center instanceof google.maps.Point);
assert.closeTo(parseFloat(center.x), 10, helper.EPSILON);
assert.closeTo(parseFloat(center.y), 20, helper.EPSILON);
}).then(function () {
map.destroy();
});
});
it("setZoom", function () { it("setZoom", function () {
var map, proxy; var map, proxy;
return ServerConnector.getProject().then(function (project) { return ServerConnector.getProject().then(function (project) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment