/usr/share/horde/ansel/js/map.js is in php-horde-ansel 3.0.5+debian0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | /**
* HordeMap support for Ansel
*
* Copyright 2009-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
*/
AnselMap = {
mapInitialized: {},
maps: {},
opts: {},
_iLayer: null,
/**
* Builds the main map widget
*
* e - dom id
* opts {
* 'onHover': Callback for handling a feature's hover event or false
* if not used.
* 'onClick': Callback for click event on the map (not a feature).
* 'imageLayer': Separate layer for thumbnails? If this is set, a
* second vector layer will be added and thumbnails will
* be placed on this layer, separate from the 'markerOnly'
* markers. Used from the Image View.
* }
*/
initMainMap: function(e, opts)
{
// Default OL StyleMap. We use a sybolizer since we have two different
// types of features (thumbnail and marker) depending on the current view.
var style = new OpenLayers.StyleMap({
'default': {
'externalGraphic': '${thumbnail}',
'backgroundGraphic': '${background}'
},
'temporary': {}
});
// Symbolizer map for Default intent
var markerStyleDefault = {
'markerOnly': {
'graphicHeight': 37,
'graphicWidth': 32,
'graphicYOffset': -37,
'backgroundXOffset': 0,
'backgroundYOffset': -42,
'backgroundGraphicZIndex': 10,
'graphicZIndex': 30
},
'noMarkerOnly': {
'backgroundWidth': 54,
'backgroundHeight': 54,
'graphicWidth': 50,
'graphicHeight': 50,
'backgroundGraphicZIndex': 20,
'graphicZIndex': 20
}
};
// Symbolizer map for Temporary intent (hover)
var markerStyleTemporary = {
'markerOnly': {},
'noMarkerOnly': {
'backgroundGraphic': Ansel.conf.pixeluri + '?c=333333'
}
};
style.addUniqueValueRules('default', 'markerOnly', markerStyleDefault);
style.addUniqueValueRules('temporary', 'markerOnly', markerStyleTemporary);
var map = this._initializeMap(e, {
'styleMap': style,
'layerSwitcher': true,
'markerLayerTitle': opts.markerLayerText,
'onBaseLayerChange': (opts.onBaseLayerChange) ? opts.onBaseLayerChange : false,
'defaultBaseLayer': opts.defaultBaseLayer
});
if (!opts.imageLayer) {
this.maps[e]._highlightControl = map.addHighlightControl({
'onHover': opts.onHover,
'layers': map.markerLayer
});
map.addClickControl({
'onClick': opts.onClick,
'layers': [map.markerLayer],
'active': [map.markerLayer]
});
} else {
this._iLayer = map.createVectorLayer({
'markerLayerTitle': opts.imageLayerText,
'styleMap': style
});
map.map.addLayers([this._iLayer]);
map.addHighlightControl({
'layers': [this._iLayer, map.markerLayer],
'onHover': opts.onHover
});
map.addClickControl({
'layers': [this._iLayer, map.markerLayer],
'active': [this._iLayer, map.markerLayer],
'onClick': opts.onClick
})
map.map.raiseLayer(map.markerLayer, 1);
map.map.raiseLayer(this._iLayer, -1);
map.map.resetLayersZIndex();
}
return map;
},
/**
* Inits the 'mini' map on the geotag widget
*
* @param string e DOM id of the minimap
*/
initMiniMap: function(e) {
return this._initializeMap(e, {
'styleMap': new OpenLayers.StyleMap(
{
'externalGraphic': Ansel.conf.markeruri,
'pointRadius': 10
}
)
});
},
/**
* Inits the main map for the manual geotag view.
*
* @param string e The DOM id of the editmap.
* @param array opts Options:
* mapClick Handler for mapclick events
* markerDragEnd Handler for feature drag events
*/
initEditMap: function(e, opts) {
return this._initializeMap(e, {
'panzoom': true,
'zoomworldicon': true,
'layerSwitcher': true,
'mapClick': opts.mapClick,
'markerDragEnd': opts.markerDragEnd,
'draggableFeatures': true,
'styleMap': new OpenLayers.StyleMap(
{
'externalGraphic': Ansel.conf.markeruri,
'backgroundGraphic': Ansel.conf.shadowuri,
'graphicHeight': 37,
'graphicWidth': 32,
'graphicYOffset': -37,
'backgroundXOffset': 0,
'backgroundYOffset': -42
}
)
});
},
_initializeMap: function(e, op)
{
if (this.mapInitialized[e]) {
return this.maps[e];
}
var o = {
'panzoom': false,
'layerSwitcher': false,
'onHover': false,
'markerDragEnd': Prototype.EmptyFunction,
'markerLayerTitle': '',
'onBaseLayerChange': false
}
var opts = Object.extend(o, op || {});
var layers = [];
if (Ansel.conf.maps.providers) {
Ansel.conf.maps.providers.each(function(l) {
var p = new HordeMap[l]();
$H(p.getLayers()).values().each(function(e) { layers.push(e); });
});
}
var mapOpts = {
elt: e,
layers: layers,
draggableFeatures: (opts.draggableFeatures) ? true : false,
panzoom: opts.panzoom,
zoomworldicon: (opts.zoomworldicon) ? opts.zoomworldicon : false,
showLayerSwitcher: opts.layerSwitcher,
useMarkerLayer: true,
markerImage: Ansel.conf.markeruri,
markerBackground: Ansel.conf.shadowuri,
pointRadius: 20,
onHover: opts.onHover,
onClick: opts.onClick,
markerDragEnd: opts.markerDragEnd,
mapClick: (opts.mapClick) ? opts.mapClick.bind(this) : Prototype.EmptyFunction,
delayed: (opts.delayed) ? true : false,
markerLayerTitle: opts.markerLayerTitle
}
if (opts.styleMap) {
mapOpts.styleMap = opts.styleMap;
}
mapOpts.onBaseLayerChange = opts.onBaseLayerChange;
this.maps[e] = new HordeMap.Map[Ansel.conf.maps.driver](mapOpts);
this.mapInitialized[e] = true;
if (opts.defaultBaseLayer) {
this.maps[e].map.setBaseLayer(this.maps[e].map.getLayersByName(opts.defaultBaseLayer).pop());
}
return this.maps[e];
},
resetMap: function(e)
{
this.mapInitialized[e] = false;
if (this.map[e]) {
this.map[e].destroy();
this.map[e] = null;
}
},
/**
* Place the event marker on the map, at point ll, ensuring it exists.
* Optionally center the map on the marker and zoom. Zoom only honored if
* center is set, and if center is set, but zoom is null, we zoomToFit().
*
* @param string e The DOM id of the map we are placing the marker on.
* @param latlon ll { 'lat': x, 'lon': y }
* @param object opts Options
* img URI for image thumbnail to use for this marker.
* image_id The image_id this marker represents
* markerOnly We should place a traditional marker, not a thumbnail.
* background The marker background URI
* image_link The URL to the image view for this marker.
* zoom We should auto zoom to this zoom level after placing.
* center Auto center the map after placing the marker.
*/
placeMapMarker: function(e, ll, opts)
{
var marker;
if (!opts) {
opts = {};
}
if (opts.img) {
if (this._iLayer && opts.markerOnly == 'noMarkerOnly') {
marker = this.maps[e].addMarker(ll, { 'layer': this._iLayer });
} else {
marker = this.maps[e].addMarker(ll);
}
marker.attributes['thumbnail'] = opts.img;
marker.attributes['image_id'] = opts.image_id;
marker.attributes['markerOnly'] = opts.markerOnly;
marker.attributes['background'] = opts.background;
marker.attributes['image_link'] = opts.image_link;
} else {
marker = this.maps[e].addMarker(ll);
}
if (opts.center) {
this.maps[e].setCenter(ll, opts.zoom);
if (!opts.zoom) {
this.maps[e].zoomToFit((this._iLayer) ? this._iLayer : false);
}
}
return marker;
},
/**
* Move an existing marker.
*
* @param string e The DOM id for the map the marker exists on.
* @param object m A marker object representing the marker
* @param latlon ll { 'lat': x, 'lon': x },
* @param object opts Options hash
* center Center map after moving?
* zoom Zoom level to set map to after moving.
*/
moveMarker: function(e, m, ll, opts)
{
this.maps[e].moveMarker(m, ll);
if (opts.center) {
this.maps[e].setCenter(ll, opts.zoom);
if (!opts.zoom) {
this.maps[e].zoomToFit();
}
}
},
/**
* Manually mark a marker as 'selected'. This has the effect of changing the
* marker's render intent to indicate it is highlighted. Has the same effect
* as hovering over the marker.
*/
selectMarker: function(e, m)
{
this.maps[e]._highlightControl.highlight(m);
},
/**
* Unselect a marker. Changes the markers render intent back to default.
* Same effect as mouseout.
*/
unselectMarker: function(e, m)
{
this.maps[e]._highlightControl.unhighlight(m);
},
/**
* Utility method for rendering a lat/lon pair.
*/
point2Deg: function(ll) {
function dec2deg(dec, lat)
{
var letter = lat ? (dec > 0 ? "N" : "S") : (dec > 0 ? "E" : "W");
dec = Math.abs(dec);
var deg = Math.floor(dec);
var min = Math.floor((dec - deg) * 60);
var sec = (dec - deg - min / 60) * 3600;
return deg + "° " + min + "' " + sec.toFixed(2) + "\" " + letter;
}
return dec2deg(ll.lat, true) + " " + dec2deg(ll.lon);
},
onDomLoad: function()
{
this.maps.each(function(x) { x.display(); });
}
}
|