var browseDataLayer;
var browseSelectControl;
var browseObjectList;
+ var areasHidden = false;
OpenLayers.Feature.Vector.style['default'].strokeWidth = 3;
OpenLayers.Feature.Vector.style['default'].cursor = "pointer";
sides: 4,
snapAngle: 90,
irregular: true,
- persist: true,
- callbacks: { done: endDrag }
+ persist: true
}
});
+ browseBoxControl.handler.callbacks.done = endDrag;
map.addControl(browseBoxControl);
map.events.register("moveend", map, showData);
map.events.triggerEvent("moveend");
+
+ $("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;
}
function showData() {
if (browseMode == "auto") {
if (map.getZoom() >= 15) {
- useMap();
+ useMap(false);
} else {
setStatus("#{I18n.t('browse.start_rjs.zoom_or_select')}");
}
if (browseBoxControl) {
browseBoxControl.destroy();
- browseBoxControl = null;
+ browseBoxControl = null;
}
if (browseActiveFeature) {
$("browse_select_box").onclick = startDrag;
- function useMap() {
+ function useMap(reload) {
var bounds = map.getExtent();
var projected = bounds.clone().transform(map.getProjectionObject(), epsg4326);
center.lat + (tileHeight / 2));
browseBounds = tileBounds;
- getData(tileBounds);
+ getData(tileBounds, reload);
browseMode = "auto";
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) {
}
}
- function getData(bounds) {
+ 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());
+ loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX(), reload);
}
}
- function loadGML(url) {
+ function loadGML(url, reload) {
setStatus("#{I18n.t('browse.start_rjs.loading')}");
$("browse_content").innerHTML = "";
- if (!browseDataLayer) {
+ var formatOptions = {
+ checkTags: true,
+ interestingTagsExclude: ['source','source_ref','source:ref','history','attribution','created_by','tiger:county','tiger:tlid','tiger:upload_uuid']
+ };
+
+ if (areasHidden) formatOptions.areaTags = [];
+
+ if (!browseDataLayer || reload) {
var style = new OpenLayers.Style();
style.addRules([new OpenLayers.Rule({
}
})]);
+ if (browseDataLayer) browseDataLayer.destroyFeatures();
+
browseDataLayer = new OpenLayers.Layer.GML("Data", url, {
format: OpenLayers.Format.OSM,
- formatOptions: {
- checkTags: true,
- interestingTagsExclude: ['source','source_ref','source:ref','history','attribution','created_by','tiger:county','tiger:tlid','tiger:upload_uuid']
- },
+ formatOptions: formatOptions,
maxFeatures: 100,
requestSuccess: customDataLoader,
displayInLayerSwitcher: false,
map.addControl(browseSelectControl);
browseSelectControl.activate();
} else {
+ browseDataLayer.destroyFeatures();
+ browseDataLayer.format(formatOptions);
browseDataLayer.setUrl(url);
}