var SYP = {
Settings: {
- MARKER_ICON: "openlayers/img/marker-blue.png",
- MARKER_ICON_HEIGHT: 25,
- MARKER_SELECT_ICON: "openlayers/img/marker-green.png",
- MARKER_SELECT_ICON_HEIGHT: 25
+ MARKER_ICON: "media/marker-normal.png",
+ MARKER_SELECT_ICON: "media/marker-selected.png",
+ MARKER_HEIGHT: 25
},
map: null,
},
createDataLayer: function(map) {
+ var defaultStyle = new OpenLayers.Style({
+ externalGraphic: this.Settings.MARKER_ICON,
+ graphicHeight: "${height}"
+ }, {
+ context: {
+ height: function(feature) {
+ var defaultHeight = SYP.Settings.MARKER_HEIGHT || 32;
+ var increase = 4 * (feature.attributes.count - 1);
+ return Math.min(defaultHeight + increase, 50);
+ }
+ }
+ });
+ var selectStyle = new OpenLayers.Style({
+ externalGraphic: this.Settings.MARKER_SELECT_ICON,
+ graphicHeight: this.Settings.MARKER_HEIGHT || 32
+ });
var styleMap = new OpenLayers.StyleMap (
- {"default": {
- externalGraphic: this.Settings.MARKER_ICON,
- graphicHeight: this.Settings.MARKER_ICON_HEIGHT
- || 32
- },
- "select": {
- externalGraphic: this.Settings.MARKER_SELECT_ICON,
- graphicHeight: this.Settings.MARKER_SELECT_ICON_HEIGHT
- || 32
- }
- });
+ {"default": defaultStyle,
+ "select": selectStyle});
var layer = new OpenLayers.Layer.GML("KML", "items.php",
{
+ strategies: [
+ new OpenLayers.Strategy.Cluster()
+ ],
styleMap: styleMap,
format: OpenLayers.Format.KML,
projection: this.map.displayProjection,
onFeatureSelect: function(feature) {
var map = feature.layer.map;
+ if (feature.attributes.count > 1) {
+ this.unselect(feature);
+ var lonlat = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);
+ map.setCenter(lonlat, map.zoom + 1);
+ return;
+ }
var permaControl = map.getControlsByClass("OpenLayers.Control.Permalink");
if (permaControl[0]) {
permaControl[0].div.style.display = "none";
popup.destroy();
}
var contentHTML;
- if (feature.attributes.name) {
+ if (feature.cluster[0].attributes.name) {
contentHTML = "<h2>" +
- feature.attributes.name +
+ feature.cluster[0].attributes.name +
"</h2>" +
- feature.attributes.description;
+ feature.cluster[0].attributes.description;
} else {
- contentHTML = feature.attributes.description;
+ contentHTML = feature.cluster[0].attributes.description;
}
if (!contentHTML || !contentHTML.length) {
this.map.events.register("movestart", this, this._unselect = function () { this.unselect(feature)});
var control = this;
popup.hide = function () {
OpenLayers.Element.hide(this.div);
- control.unselect(feature);
+ control.unselectAll();
};
map.addPopup(popup);
feature.popup = popup;
+ var anchor = popup.div.getElementsByTagName("a")[0];
+ if (anchor) {
+ anchor.onclick = function() {
+ SYP.showBigImage(this.href);
+ return false;
+ }
+ }
+ },
+
+ showBigImage: function (href) {
+ try {
+ document.getElementById('bigimg_container').style.display = "table";
+ } catch(e) {
+ document.getElementById('bigimg_container').style.display = "block";
+ }
+ var maxHeight = document.body.clientHeight * 0.9;
+ var maxWidth = document.body.clientWidth * 0.9;
+ document.getElementById('bigimg').style.height = "";
+ document.getElementById('bigimg').style.width = "";
+ document.getElementById('bigimg').style.maxHeight = maxHeight + "px";
+ document.getElementById('bigimg').style.maxWidth = maxWidth + "px";
+ document.getElementById('bigimg').onload = function () {
+ var icon = document.getElementById('bigimg_close');
+ icon.style.top = this.offsetTop;
+ icon.style.left = this.offsetLeft + this.clientWidth - icon.clientWidth;
+
+ var heightRatio = this.clientHeight / parseInt(this.style.maxHeight);
+ var widthRatio = this.clientWidth / parseInt(this.style.maxWidth);
+ if (heightRatio > 1 || widthRatio > 1) {
+ if (heightRatio > widthRatio) {
+ this.style.height = this.style.maxHeight;
+ } else {
+ this.style.width = this.style.maxWidth;
+ }
+ }
+
+ };
+ document.getElementById('bigimg').src = href;
+ },
+
+ closeBigImage: function() {
+ document.getElementById('bigimg').src = "";
+ document.getElementById('bigimg').parentNode.innerHTML = document.getElementById('bigimg').parentNode.innerHTML;
+ document.getElementById('bigimg_container').style.display = "none";
},
Utils: {