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

fitBounds function for JS API

parent 87aa89fc
No related branches found
No related tags found
1 merge request!12Resolve "new JS API calls"
......@@ -229,7 +229,6 @@ function getElements(elementIdentifiers, customMap) {
}
function getReactionsForElements(elementIdentifiers, customMap) {
var elementsByModelId = [];
for (var i = 0; i < elementIdentifiers.length; i++) {
var identifiedElement = new IdentifiedElement(elementIdentifiers[i]);
......@@ -369,6 +368,20 @@ function createResult(customMap) {
}
return submap.setCenter(new google.maps.Point(params.x, params.y));
},
fitBounds : function(params) {
var submap = customMap.getSubmapById(params.modelId);
if (submap === null) {
throw new Error("Unknown modelId: " + params.modelId);
}
var p1 = new google.maps.Point(params.x1, params.y1);
var p2 = new google.maps.Point(params.x2, params.y2);
var latLng1 = submap.fromPointToLatLng(p1);
var latLng2 = submap.fromPointToLatLng(p2);
var bounds = new google.maps.LatLngBounds();
bounds.extend(latLng1);
bounds.extend(latLng2);
return submap.getGoogleMap().fitBounds(bounds);
},
setZoom : function(params) {
var submap = customMap.getSubmapById(params.modelId);
if (submap === null) {
......
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