-<div style="padding:0px 10px; width:100%">
+<div style="padding:0px 10px">
<div style="text-align: center">
<p style="margin-top: 10px">
<a id="use_map" display="hidden" href="#">View Data For Current Map View</a>
map.addControl(box);
map.events.register("moveend", map, showData);
map.events.triggerEvent("moveend");
+ map.dataLayer.stopBrowse = stopBrowse;
browsing = true;
}
}
function stopBrowse() {
- if (gml) {
- gml.destroy();
- gml = null;
- }
- if (sf) {
- sf.destroy();
- sf = null;
- }
- if (currentFeature) {
- currentFeature.destroy();
- currentFeature = null;
- }
- map.events.unregister("moveend", map, showData);
- browsing = false;
+ if (browsing) {
+ browsing = false;
+ map.dataLayer.stopBrowse = null;
+ if (gml) {
+ gml.destroy();
+ gml = null;
+ }
+ if (sf) {
+ sf.destroy();
+ sf = null;
+ }
+ if (currentFeature) {
+ currentFeature.destroy();
+ currentFeature = null;
+ }
+ map.dataLayer.setVisibility(false);
+ map.events.unregister("moveend", map, showData);
+ }
}
function startDrag() {
function endDrag(bbox) {
var bounds = bbox.getBounds();
box.deactivate();
+ currentBounds = bounds;
getData(bounds);
$("drag_box").innerHTML = "Manually select a different area";
mode = "manual";
gml = new OpenLayers.Layer.GML("Data",url,
{format: OpenLayers.Format.OSM, formatOptions: {checkTags: true},
maxFeatures: 100, requestSuccess: customDataLoader,
+ displayInLayerSwitcher: false,
styleMap: new OpenLayers.StyleMap({'default': style, 'select': {'strokeColor': '#0000ff', strokeWidth: 8}})
}
);
<%= render :partial => 'search' %>
<div id="map">
-<div id="datalink"><%= link_to_remote 'See Data', {:url => {:controller => 'browse', :action => 'start'}}, {:href => url_for( {:controller => 'browse', :action => 'index'}), :id => 'browseanchor', :title => 'browse data'} %></div>
<div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
</div>
wrapDateLine: true
});
map.addLayer(maplint);
+ var data = new OpenLayers.Layer.Data("Data", {'visibility': false});
+ map.addLayer(data);
+ map.dataLayer = data;
var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
markers = new OpenLayers.Layer.Markers("Markers", {
CLASS_NAME: "OpenLayers.Layer.OSM.Maplint"
});
+
+OpenLayers.Layer.Data = OpenLayers.Class(OpenLayers.Layer, {
+ setVisibility: function(vis) {
+ OpenLayers.Layer.prototype.setVisibility.apply(this, arguments);
+ if (!this.map) { return; }
+ if (vis) {
+ new Ajax.Request('/browse/start', {asynchronous:true, evalScripts:true});
+ } else {
+ if (this.stopBrowse) {
+ this.stopBrowse();
+ closeSidebar();
+ }
+ }
+ }
+});