+
+ return false;
+ }
+
+ function hideAreas() {
+ $("browse_hide_areas_box").innerHTML = "#{I18n.t('browse.start_rjs.show_areas')}";
+ $("browse_hide_areas_box").style.display = "inline";
+ $("browse_hide_areas_box").onclick = showAreas;
+
+ areasHidden = true;
+
+ useMap(true);
+ }
+
+ function showAreas() {
+ $("browse_hide_areas_box").innerHTML = "#{I18n.t('browse.start_rjs.hide_areas')}";
+ $("browse_hide_areas_box").style.display = "inline";
+ $("browse_hide_areas_box").onclick = hideAreas;
+
+ areasHidden = false;
+
+ useMap(true);
+ }
+
+ $("browse_select_view").onclick = useMap;
+
+ function endDrag(bbox) {
+ var bounds = bbox.getBounds();
+ var projected = bounds.clone().transform(map.getProjectionObject(), epsg4326);
+
+ browseBoxControl.deactivate();
+ browseBounds = projected;
+ getData(bounds);
+
+ browseMode = "manual";
+
+ $("browse_select_box").innerHTML = "#{I18n.t('browse.start_rjs.manually_select')}";
+ $("browse_select_view").style.display = "inline";
+ }
+
+ function displayFeatureWarning() {
+ clearStatus();
+
+ var div = document.createElement("div");
+
+ var p = document.createElement("p");
+ p.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.loaded_an_area_with_num_features')}", { num_features: browseFeatureList.length })));
+ div.appendChild(p);
+
+ var input = document.createElement("input");
+ input.type = "submit";
+ input.value = "#{I18n.t('browse.start_rjs.load_data')}";
+ input.onclick = loadFeatureList;
+ div.appendChild(input);
+
+ $("browse_content").innerHTML = "";
+ $("browse_content").appendChild(div);
+ }
+
+ function loadFeatureList() {
+ browseDataLayer.addFeatures(browseFeatureList);
+ browseDataLayer.events.triggerEvent("loadend");
+
+ browseFeatureList = [];
+
+ return false;
+ }
+
+ function customDataLoader(request) {
+ if (this.map.dataLayer.active) {
+ var doc = request.responseXML;
+
+ if (!doc || !doc.documentElement) {
+ doc = request.responseText;
+ }
+
+ var options = {};
+
+ OpenLayers.Util.extend(options, this.formatOptions);
+
+ if (this.map && !this.projection.equals(this.map.getProjectionObject())) {
+ options.externalProjection = this.projection;
+ options.internalProjection = this.map.getProjectionObject();
+ }
+
+ var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options);
+
+ browseFeatureList = gml.read(doc);
+
+ if (!this.maxFeatures || browseFeatureList.length <= this.maxFeatures) {
+ loadFeatureList();
+ } else {
+ displayFeatureWarning();
+ }
+ }
+ }
+
+ function getData(bounds, reload) {
+ var projected = bounds.clone().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
+ var size = projected.getWidth() * projected.getHeight();
+
+ if (size > #{MAX_REQUEST_AREA}) {
+ setStatus(i18n("#{I18n.t('browse.start_rjs.unable_to_load_size', :max_bbox_size => MAX_REQUEST_AREA)}", { bbox_size: size }));
+ } else {
+ loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX(), reload);
+ }
+ }
+
+ function loadGML(url, reload) {
+ setStatus("#{I18n.t('browse.start_rjs.loading')}");
+ $("browse_content").innerHTML = "";
+
+ var formatOptions = {
+ checkTags: true,
+ interestingTagsExclude: ['source','source_ref','source:ref','history','attribution','created_by','tiger:county','tiger:tlid','tiger:upload_uuid']