aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
Commit message (Collapse)AuthorAgeLines
* Improve handling of loading spinner display.Matthew Somerville2018-05-31-5/+17
| | | | | | | | | Going back to /around from /report/new can trigger loadend (and the spinner hiding function) twice (if the strategy activation starts a read), with triggerRead aborting that read and triggering the event itself. This means the spinner is not displayed, as the count falls below 0. We could pin the count above 0, but instead let’s log each layer ID while ‘active’ and switch off when they’re all gone.
* Some IE8/old JS workarounds.Matthew Somerville2018-05-02-1/+1
|
* Drop unused copy of function.Matthew Somerville2018-04-30-14/+0
| | | | This is already defined in fixmystreet.utils further up.
* Fix issues with new report pin, improve cursor.Matthew Somerville2018-03-26-1/+1
| | | | | | | | | | The "coerce pin ID to integer" behaviour to fix a previous issue was coercing undefined to NaN, which then caused other problems with the new report pin, such as fading out when hovered, and being the wrong size. Also improve the cursor handling, showing the grab/ grabbing cursors where available.
* Fix race condition making a new report.Matthew Somerville2018-03-26-0/+4
| | | | | | If you started a new report by clicking the map before the server had responded with the map list pins, when they did arrive they would replace the new report pin.
* Update some tight JS coupling to use events.Matthew Somerville2018-03-13-6/+1
| | | | Remove 'hooks' functions, and Split out USRN handling to its own object.
* Populate `usrn` field with USRN of clicked asset, if availableDave Arter2018-02-22-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | Some cobrands require reports to include the USRN of the clicked road. This commit allows an asset layer to be added and designated as a 'USRN provider' by setting its `usrn_field` property when calling fixmystreet.assets.add. Initially this feature used OpenLayers' getFeatureFromEvent method, however that doesn't work if the layer isn't topmost. This is because it uses the clicked element in the DOM to determine which feature was clicked. This doesn't work if the layer you're trying to get the feature from wasn't actually the DOM element that was clicked. Instead, we add a new method, OpenLayers.Layer.Vector.getFeatureAtPoint method which takes a Point object and iterates through the features' geometries to find the matching point. To make things a little more user-friendly, if an asset isn't clicked directly we find the closest to the clicked point and use that for the USRN. To accomplish this, this commit factors out the ‘select nearest asset’ code into a new method OpenLayers.Layer.Vector.getNearestFeature, which takes a Point and a distance threshold and finds the nearest feature.
* Show loading spinner on map for assets as well as markersDave Arter2018-02-08-2/+2
|
* Factor map loading spinner code out so multiple things can load at onceDave Arter2018-02-08-6/+28
|
* [Zurich] Add filters to /reports, fix photo bug.Matthew Somerville2018-01-18-1/+1
| | | | The photo JavaScript needs including in case a report is pulled in.
* Zoom out as much as necessary, even on mobile.Matthew Somerville2018-01-15-3/+0
| | | | | This also fixes an inconsistency between what you can see on the map and the list of reports underneath.
* Only work out bounds/resolution on BBOX strategiesMatthew Somerville2018-01-10-4/+7
| | | | The /my page uses a Fixed strategy which cannot do this.
* Add JSHint configuration, tidy up any warnings.Matthew Somerville2018-01-10-18/+20
|
* Second, more prominent Hide Pins linkZarino Zappia2017-11-27-3/+6
| | | | An experiment towards fixing #525.
* Add pagination to around page.Matthew Somerville2017-11-06-17/+83
|
* Remove Show all pins link and on_map_list_limit.Matthew Somerville2017-11-06-36/+0
| | | | | /around will now show all reports all the time, but we are about to introduce pagination to stop that.
* Have /around ajax use same format as others.Matthew Somerville2017-11-02-4/+4
| | | | | Both /reports and /my work by using the same URL with ajax=1. We should use the same on /around for consistency.
* Make sure pin ID is an integer.Matthew Somerville2017-09-07-2/+3
| | | | | | | | | | The JavaScript assumes it is, but due to a string comparison in DBIx::Class [1] when a has_many prefetch is in use (as it is on a /reports page when a shortlist-using staff user is logged in) all IDs bar the first were being given an internal string value and JSON encoding was outputting them as a string. [1] https://github.com/dbsrgits/dbix-class/blob/v0.08209/lib/DBIx/Class/ResultSet.pm#L1331
* [Zurich] Upgrade OpenLayers to master, matching others.Matthew Somerville2017-08-18-12/+1
|
* Make sure /around permalink/redirect have js paramMatthew Somerville2017-08-18-0/+4
| | | | | The change in 17e38922 would not deal with the URL construted by the map permalink code, or the redirect after inspection.
* Fix replaced sidebar losing hover behaviour.Matthew Somerville2017-08-17-1/+1
| | | | | If the list was replaced by JavaScript, the event handlers were being dropped. Switch the handlers to the parent that remains present.
* Refactor /around list code to share with others.Matthew Somerville2017-08-17-4/+0
| | | | | Both /reports and /my share an ID and a /reports/ajax function, use these also on /around (and share ajax/non-ajax code).
* [Zurich] Fix map on /reportsDave Arter2017-08-14-1/+4
| | | | | | | | | | | | | | | | | | A seemingly unrelated change in ef6ffbdb was causing JS errors on the /reports page which meant the map loading spinner was permanently present. This commit fixes that, and also fixes another bug which was uncovered where the ?ajax=1 param was being ignored by the Zürich /reports page, leading to HTML being returned and another JS error. The call to `new OpenLayers.Bounds` in OpenLayers.Strategy.FixMyStreet.getMapBounds was causing three of the 4 bounds params to be lost when run on OpenLayers 2.11, as this version doesn’t accept an array to the Bounds constructor. This in turn was using an invalid `bbox` parameter (only the west value was present) in the AJAX call to /reports which returned a 500 error. This then crashed the JS and caused the loading spinner to get stuck.
* Use standard JS translation for show/hide pins.Matthew Somerville2017-08-03-17/+8
|
* [FixaMinGata] Consolidate with upstream.Jon Kristensen2017-07-07-1/+2
| | | | | Add hook for post-title field content in report form. Update translations.
* Allow cobrands to define pin colour for new reportsZarino Zappia2017-06-09-1/+1
| | | | | | Previously, a green marker would be used for reports as they were being created. Now, cobrands can override `pin_new_report_colour` to show a different pin image when users are creating a new report.
* Fix linting errorspezholio2017-05-23-51/+48
|
* Allow inspectors to shortlist all reports in viewpezholio2017-05-05-2/+7
| | | | If zoom level is >= 14, then inspectors can click a button that marks all reports in the map view as shortlisted
* On /reports maps, only include reports in view.Matthew Somerville2017-04-13-2/+36
| | | | | | | | | Update the reports with a bounding box, similar to on around pages. This is made slightly trickier because we don't want to do anything on page load (we already have the pins), we need to reload when the zoom changes, and we don't want the strategy to get confused by its first redraw, e.g. on pin hover, We also need to turn off the zoom- to-bounds if we've got a bounding box in the URL.
* Use lat/lon on inspection form if local coordinates aren’t availableDave Arter2017-03-30-0/+2
|
* Show loading indicator when loading pinspezholio2017-03-17-11/+6
|
* Display nearby candidate reports when marking as duplicateDave Arter2016-12-13-36/+50
| | | | | | | | - Use Problem->pin_data for single report page - Promote markers_highlight to fixmystreet.maps API We want to highlight map pins on the duplicate report selection UI, so let's use what's already there instead of writing something new. - Make sure duplicate report pins aren’t draggable
* Load OpenLayers stylesheet directly, not via JS.Matthew Somerville2016-12-09-0/+1
| | | | | This lets us version and cache-bust it as necessary, plus let browser decide how to load it, we're always going to need it.
* Add sort order options to list pages.Matthew Somerville2016-11-04-13/+17
| | | | | | | | Includes newest, oldest, least/most recently updated, and most comments. The default remains the same, which is last updated on /reports, and newest on /my and /around (the latter plus not-in-view sorted-by-distance ones).
* Merge branch 'reports-area-as-a-hole'Matthew Somerville2016-10-24-8/+51
|\
| * Invert display of areas on body pages.Matthew Somerville2016-10-21-8/+51
| | | | | | | | | | This makes it easier to use the map, as the land outside the area is shaded, rather than the area itself.
* | Store and use initial URL to fix JavaScript bugs.Matthew Somerville2016-10-21-1/+1
|/ | | | | | | | | | | | | If you were on a body page, selected a report, then another report, the "Back to all reports" link then had an incorrect URL. Also, going "Back to all reports" after one report would fetch an incorrect Ajax query of reports to show (as the URL had not yet been updated). Both of these are fixed by storing the URL on page load, and using that for the "Back to all reports" link and the URL used by the Ajax call. There is still an issue with the URL shown if you filter, then select a report, then click "Back to all reports", but the contents are okay.
* Fix map pin clicking in IE11.Matthew Somerville2016-10-21-3/+3
| | | | | | It turns out that whilst IE9+ defines MouseEvent, it's not in the form that can be used as a constructor until Edge. To fix this we check that MouseEvent is a function before using it as one.
* Update pagination when status/categories changed.Matthew Somerville2016-10-18-0/+4
|
* Add ajax pin fetching to reports/my pages.Matthew Somerville2016-10-14-0/+25
| | | | | This matches the behaviour on /around, and prevents a refresh when changing the state or category filters.
* Improve history API URL when query string empty.Matthew Somerville2016-10-14-1/+11
|
* Allow multiple selections in report list filter.Zarino Zappia2016-10-13-9/+35
| | | | | | This lets people filter by multiple categories or states. It uses our jQuery multi-select plugin to turn the <select multiple>s into little overlay lists of checkboxes. HTML5 history is also supported.
* Add inspector report detail viewDave Arter2016-09-06-0/+55
| | | | | | | | | | | | | Users with the `report_inspect` permission can click a new 'inspect' button on a report page to input more detailed problem information into a new form that appears in a column alongside the report detail. - Inspector data is stored in problem's 'extra' field - Report category/state can be edited - Location can be changed by dragging the pin or HTML5 geolocation (Factored out Zurich admin pin drag into own function) For mysociety/fixmystreetforcouncils#22
* Make sure PanZoom works in older OpenLayers.Matthew Somerville2016-08-19-34/+8
| | | | | Remove unused code that is same as upstream (it was added when the map middle didn't match the visible middle), and the world button.
* Move non-JavaScript pan/zoom to same as with JS.Matthew Somerville2016-08-17-7/+18
| | | | | No need to use old OpenLayers PanZoom defaults, or load images we don't want to use.
* Factor out most inline JavaScript.Matthew Somerville2016-08-16-10/+0
| | | | | No need for a special no-map case in the filters case, as all pages now have fixmystreet.page set if needed.
* Do HTML class and JS variable setting ASAP.Matthew Somerville2016-08-16-1/+1
|
* Work correctly for alt-click/cmd-click etc.Matthew Somerville2016-07-14-3/+30
|
* Fix a few JavaScript issues with reports pages.Matthew Somerville2016-07-12-1/+6
| | | | | | | Don't stringify pin problem ID, as get_marker_by_id assumes it will be an integer; only activate the bounding box strategy if it exists; make sure a refresh of the markers happens when going back to the list; set the Back link on a pulled-in report to the current URL.
* Move to using pushState for new report.Zarino Zappia2016-07-11-30/+31
| | | | | Update the URL whenever location of pin is updated (first time, drag, or reclick), make sure it works when clicking back.