Commit dae08603 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

center button has a css selector

parent 6404d103
...@@ -303,6 +303,11 @@ ...@@ -303,6 +303,11 @@
cursor: pointer; cursor: pointer;
} }
.minerva-center-map-button > i.fa {
font-size: 24px;
color: grey
}
/* twitter typeahead */ /* twitter typeahead */
.tt-query /* UPDATE: newer versions use tt-input instead of tt-query */ .tt-query /* UPDATE: newer versions use tt-input instead of tt-query */
{ {
......
...@@ -172,6 +172,19 @@ CustomMap.prototype.createLogo = function () { ...@@ -172,6 +172,19 @@ CustomMap.prototype.createLogo = function () {
}); });
logoControlDiv.appendChild(logo); logoControlDiv.appendChild(logo);
this.getMapCanvas().addRightBottomControl(logoControlDiv); this.getMapCanvas().addRightBottomControl(logoControlDiv);
this.getMapCanvas().addRightTopControl(Functions.createElement({
type: "a",
content: "<i class='fa fa-crosshairs'></i>&nbsp;",
title: "center map",
className: "minerva-center-map-button",
href: "#",
onclick: function () {
var bounds = new Bounds(new Point(0, 0), new Point(self.getWidth(), self.getHeight()));
return self.getMapCanvas().fitBounds(bounds);
},
xss: false
}));
}; };
/** /**
......
...@@ -36,7 +36,6 @@ function GoogleMapsApiCanvas(element, options) { ...@@ -36,7 +36,6 @@ function GoogleMapsApiCanvas(element, options) {
var self = this; var self = this;
self.setGoogleMap(new google.maps.Map(element, self.prepareGoogleMapOptions(options))); self.setGoogleMap(new google.maps.Map(element, self.prepareGoogleMapOptions(options)));
self.setupBackgroundOverlays(options.backgroundOverlays); self.setupBackgroundOverlays(options.backgroundOverlays);
self.addCenterButton();
google.maps.event.addListener(this.getGoogleMap(), "click", function (e) { google.maps.event.addListener(this.getGoogleMap(), "click", function (e) {
return self.callListeners("click", {point: self.fromLatLngToPoint(e.latLng)}); return self.callListeners("click", {point: self.fromLatLngToPoint(e.latLng)});
...@@ -167,27 +166,16 @@ GoogleMapsApiCanvas.prototype.prepareGoogleMapOptions = function (options) { ...@@ -167,27 +166,16 @@ GoogleMapsApiCanvas.prototype.prepareGoogleMapOptions = function (options) {
}; };
/** /**
* Adds center button to the map. *
* @param {HTMLElement} element
*/ */
GoogleMapsApiCanvas.prototype.addCenterButton = function () { GoogleMapsApiCanvas.prototype.addRightTopControl = function (element) {
var self = this; var wrapper = Functions.createElement({
var centerDiv = Functions.createElement({
type: "div", type: "div",
style: "padding:5px" style: "padding:5px"
}); });
var centerButton = Functions.createElement({ wrapper.appendChild(element);
type: "a", this.getGoogleMap().controls[google.maps.ControlPosition.RIGHT_TOP].push(wrapper);
content: "<i class='fa fa-crosshairs' style='font-size:24px;color:grey'></i>&nbsp;",
title: "center map",
href: "#",
onclick: function () {
var bounds = new Bounds(new Point(0, 0), new Point(self.getWidth(), self.getHeight()));
return self.fitBounds(bounds);
},
xss: false
});
centerDiv.appendChild(centerButton);
self.getGoogleMap().controls[google.maps.ControlPosition.RIGHT_TOP].push(centerDiv);
}; };
......
...@@ -92,7 +92,6 @@ function OpenLayerCanvas(element, options) { ...@@ -92,7 +92,6 @@ function OpenLayerCanvas(element, options) {
]) ])
}); });
self.setOpenLayersMap(map); self.setOpenLayersMap(map);
self.addCenterButton();
map.on("click", function (e) { map.on("click", function (e) {
var features = []; var features = [];
...@@ -317,25 +316,16 @@ OpenLayerCanvas.prototype.addRightBottomControl = function (element) { ...@@ -317,25 +316,16 @@ OpenLayerCanvas.prototype.addRightBottomControl = function (element) {
}; };
/** /**
* Adds center button to the map. *
* @param {HTMLElement} element
*/ */
OpenLayerCanvas.prototype.addCenterButton = function () { OpenLayerCanvas.prototype.addRightTopControl = function (element) {
var self = this; var self = this;
var wrapper = Functions.createElement({ var wrapper = Functions.createElement({
type: "div", type: "div",
className: "ol-control minerva-ol-top-right" className: "ol-control minerva-ol-top-right"
}); });
wrapper.appendChild(Functions.createElement({ wrapper.appendChild(element);
type: "a",
content: "<i class='fa fa-crosshairs' style='font-size:24px;color:grey'></i>&nbsp;",
title: "center map",
href: "#",
onclick: function () {
var bounds = new Bounds(new Point(0, 0), new Point(self.getWidth(), self.getHeight()));
return self.fitBounds(bounds);
},
xss: false
}));
this.getOpenLayersMap().addControl(new ol.control.Control({element: wrapper})); this.getOpenLayersMap().addControl(new ol.control.Control({element: wrapper}));
}; };
......
...@@ -36,11 +36,6 @@ describe('GoogleMapsApiCanvas', function () { ...@@ -36,11 +36,6 @@ describe('GoogleMapsApiCanvas', function () {
}); });
it("centerButton", function () {
var canvas = new GoogleMapsApiCanvas(testDiv, testOptions);
return canvas.getGoogleMap().controls[google.maps.ControlPosition.RIGHT_TOP][0].firstChild.onclick();
});
it("latLngToTile", function () { it("latLngToTile", function () {
var canvas = new GoogleMapsApiCanvas(testDiv, testOptions); var canvas = new GoogleMapsApiCanvas(testDiv, testOptions);
......
Supports Markdown
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