Skip to content

Commit

Permalink
[Street Manager] Only activate when report started
Browse files Browse the repository at this point in the history
Previously all map pans on /around were hitting
the Street Manager API unnecessarily.
  • Loading branch information
davea authored and dracos committed Jan 16, 2025
1 parent 1e500b4 commit 816de34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 16 additions & 2 deletions web/cobrands/fixmystreet-uk-councils/roadworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ var roadworks_defaults = {
format_class: OpenLayers.Format.GeoJSON,
stylemap: fixmystreet.assets.stylemap_invisible,
non_interactive: true,
always_visible: true,
asset_category: [],
always_visible: false,
nearest_radius: 100,
road: true,
name: "Street Manager",
actions: {
found: function(layer, feature) {
if (fixmystreet.roadworks.filter(feature)) {
Expand Down Expand Up @@ -92,6 +94,18 @@ fixmystreet.roadworks.filter = function(feature) {
return !categories.length || OpenLayers.Util.indexOf(categories, category) != -1;
};

fixmystreet.assets.add(roadworks_defaults);
var roadworks_layer = fixmystreet.assets.add(roadworks_defaults);

// Don't want to activate it until they start to make a report
fixmystreet.roadworks.activate = function(){
roadworks_layer.fixmystreet.always_visible = true;
roadworks_layer.setVisibility(true);
};

$(function(){
if (fixmystreet.page === 'new') {
fixmystreet.roadworks.activate();
}
});

})();
6 changes: 6 additions & 0 deletions web/js/map-OpenLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ $.extend(fixmystreet.utils, {
drag.activate();
}

// Only now do we want to activate the Street Manager layer, if it's
// present, as we haven't needed it until now.
if (fixmystreet.roadworks) {
fixmystreet.roadworks.activate();
}

fixmystreet.maps.hide_keyboard_instructions();

// check to see if markers are visible. We click the
Expand Down

0 comments on commit 816de34

Please sign in to comment.