- function setHome( e ) {
- var lonlat = map.getLonLatFromViewPortPx(e.xy)
-
- var lon_deg = (lonlat.lon / 20037508.34) * 180;
- var lat_deg = (lonlat.lat / 20037508.34) * 180;
- var PI = 3.14159265358979323846;
- lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
- var homerow = document.getElementById( 'homerow' );
- var home_lat = document.getElementById( 'home_lat' );
- var home_lon = document.getElementById( 'home_lon' );
- homerow.className = '';
- home_lat.value = lat_deg;
- home_lon.value = lon_deg;
- if( marker ) {
- markers.removeMarker(marker);
- }
- marker = new OpenLayers.Marker(lonlat);
- markers.addMarker(marker);
+ function setHome( e ) {
+ closeMapPopup();
+
+ if (document.getElementById('updatehome').checked) {
+ var merc = map.getLonLatFromViewPortPx(e.xy);
+ var lonlat = mercatorToLonLat(merc);
+
+ document.getElementById('homerow').className = '';
+ document.getElementById('home_lat').value = lonlat.lat;
+ document.getElementById('home_lon').value = lonlat.lon;
+
+ if (marker) {
+ removeMarkerFromMap(marker);
+ }
+
+ marker = addMarkerToMap(merc, null, "Your location");