+ function startMarker() {
+ $("add_marker").innerHTML='#{I18n.t('export.start_rjs.click_add_marker')}';
+
+ if (!markerLayer) {
+ markerLayer = new OpenLayers.Layer.Vector("",{
+ displayInLayerSwitcher: false,
+ style: {
+ externalGraphic: OpenLayers.Util.getImagesLocation() + "marker.png",
+ graphicXOffset: -10.5,
+ graphicYOffset: -25,
+ graphicWidth: 21,
+ graphicHeight: 25
+ }
+ });
+ map.addLayer(markerLayer);
+
+ markerControl = new OpenLayers.Control.DrawFeature(markerLayer, OpenLayers.Handler.Point);
+ map.addControl(markerControl);
+
+ markerLayer.events.on({ "featureadded": endMarker });
+ }
+
+ markerLayer.destroyFeatures();
+ markerControl.activate();
+
+ return false;
+ }
+
+ $("add_marker").onclick = startMarker;
+
+ function endMarker(event) {
+ markerControl.deactivate();
+
+ $("add_marker").innerHTML = "#{I18n.t('export.start_rjs.change_marker')}";
+ $("marker_inputs").style.display = "block";
+
+ var epsg4326 = new OpenLayers.Projection("EPSG:4326");
+ var epsg900913 = new OpenLayers.Projection("EPSG:900913");
+ var geom = event.feature.geometry.clone().transform(epsg900913, epsg4326);
+
+ $("marker_lon").value = geom.x.toFixed(5);
+ $("marker_lat").value = geom.y.toFixed(5);
+
+ htmlUrlChanged();
+ }
+
+ function clearMarker() {
+ $("marker_lon").value = "";
+ $("marker_lat").value = "";
+ $("marker_inputs").style.display = "none";
+ $("add_marker").innerHTML = "#{I18n.t('export.start_rjs.add_marker')}";
+
+ if (markerLayer) {
+ markerControl.destroy();
+ markerLayer.destroy();
+ markerLayer = null;
+ markerControl = null;
+ }
+ }
+