/usr/share/horde/ansel/js/map_edit.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 | /**
* Class for managing a HordeMap for manually geocoding images.
*
* 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>
*/
AnselMapEdit = Class.create({
_marker: null,
_map: null,
_geocoder: null,
_opts: null,
_img: null,
initialize: function(img, opts)
{
this._img = img[0];
this._opts = Object.extend(
{
'geocoder': 'Null'
},
opts
);
this._map = AnselMap.initEditMap('ansel_map', {
'mapClick': this._mapClickHandler.bind(this),
'markerDragEnd': this._markerMoveHandler.bind(this)
});
this._geocoder = new HordeMap.Geocoder[this._opts.geocoder](this._map, 'ansel_map');
if (this._img.image_location) {
this.setLocation(
this._img.image_latitude,
this._img.image_longitude,
this._img.image_location);
}
},
placeMapMarker: function(ll)
{
if (!this._marker) {
this._marker = AnselMap.placeMapMarker(
'ansel_map',
ll,
{ 'center': true, 'zoom': 5 }
);
} else {
AnselMap.moveMarker(
'ansel_map',
this._marker,
ll,
{ 'center': true, 'zoom': 5 }
);
}
},
setLocation: function(lat, lon, loc)
{
this.placeMapMarker({ 'lat': lat, 'lon': lon });
this._updateFields({ 'lat': lat, 'lon': lon }, loc);
},
geocode: function(loc)
{
this._geocoder.geocode(
loc,
this._geocodeCallback.curry(loc).bind(this),
this._onError.bind(this));
},
save: function()
{
new Ajax.Request(this._opts.ajaxuri, {
method: 'post',
parameters: {
action: 'geotag',
img: this._opts.image_id,
lat: this._marker.getLonLat().lat,
lng: this._marker.getLonLat().lon
},
onComplete: function(transport) {
if (transport.responseJSON.response > 0) {
window.opener.location.href = window.opener.location.href;
window.close();
}
}
});
},
_geocodeCallback: function(loc, r)
{
this.setLocation(r[0].lat, r[0].lon, loc);
},
_mapClickHandler: function(p)
{
if (!this._marker) {
this._marker = AnselMap.placeMapMarker('ansel_map', p.lonlat);
} else {
this._map.moveMarker(this._marker, p.lonlat);
}
this._geocoder.reverseGeocode(
p.lonlat,
this._getLocationCallback.bind(this),
this._onError.bind(this));
},
_markerMoveHandler: function(r)
{
this._geocoder.reverseGeocode(
r.getLonLat(),
this._getLocationCallback.bind(this),
this._onError.bind(this)
);
},
_getLocationCallback: function(r)
{
// For privacy concerns, we don't return street address level data.
if (r.length) {
for (var i = 0; i < r.length; i++) {
if (r[i].precision === 1) {
$('ansel_locationtext').update(r[i].address);
$('ansel_latlng').update(AnselMap.point2Deg(r[i]));
break;
}
}
} else {
$('ansel_locationtext').update('');
$('ansel_latlng').update('');
}
},
_updateFields: function(ll, loc)
{
$('ansel_locationtext').update(loc);
$('ansel_latlng').update(AnselMap.point2Deg(ll));
},
_onError: function(r)
{
$('ansel_locationtext').update('');
}
});
|