Feature: Regional map on the Home page.
Title
Regional map on the Home page.
Id
0052
Requestor
Ian
Status
Closed, 6 Sep 2009 03:43
Progress




Description
With the expansion of Tracks to cover multiple regions, it might be helpful to put a regional map on the Home page.
The straightforward version of this map could have a map of NZ with a marker at the centre of each region. That is, much like the current region maps, which have a marker for each area within that region.
A more sophisticated map could have the country divided into regions using something like the Regional Council boundary data. However, the Regional Councils might be a bit big, so perhaps some custom regional definition would be more appropriate?
Taking this idea a step further, it should be possible to make the map interactive, doing things like highlighting a region on mouseover event and popping up an information window with a description of, and link to, that region when it is clicked.
More broadly, this raises the question of how to define regions? For example, instead of Christchurch being a region, should it be an area within the Canterbury region; similarly, should Queenstown be an area within the Otago region? Or would some other categorization be more appropriate?
Created
29 Jun 2009 21:09
Updated
6 Sep 2009 03:43


Comments
If the Regional Council boundaries are a bit coarse, then perhaps the regions used by the MetService would be better? There are more regions, each of which is a more manageable size.
Ian, 30 Jun 2009 20:41
This is absolutely required. The home page is becoming a bit of a mess. The order of the Regions needs some attention too. Alphabetical doesn't seem right for that level.
Jonny, 6 Aug 2009 16:32
Ording the list of regions from north to south would seem reasonable, and would tie in well with a map of NZ.
Ian, 6 Aug 2009 20:13
I have done an implementation of this, now live. On the issue of defining regions I think I will just let it run for a while and see what happens.
Jonny, 18 Aug 2009 09:33
Nice. The ability to zoom in/out might be useful if there are several fairly small regions closely packed, but it isn't needed at the moment.
Ian, 18 Aug 2009 10:30
Can do. Do you think the Areas of a Region should be represented like this too? Easy to re-use the polygons thing.
Jonny, 18 Aug 2009 14:30
It would be nice to have the Region maps show Areas as polygons, just like on the home page map.
That raises the question of how to create the polygons? Ideally they would be drawn/edited directly on the Region map – like drawing tracks directly, as in 0058. However, that might be a lot of work and possibly not worth it. An alternative would be to upload a polygon drawn in Google Earth.
One issue that might arise is where an area is entirely within another area – for example, Victoria Park might be contained within Port Hills.
Also, some areas are very small – for example, Karori Park – so may not display well when zoomed out to show a whole Region.
As a refinement of the home page map (and possibly Region maps), it would be good to display the Region name on mouseover. The Google Maps API doesn't seem to have that functionality natively, but various extensions provide it – such as Map Tooltip.
Ian, 18 Aug 2009 20:39
Thanks for the Map Tooltip reference, I looked at the gpolygon API and there didn't seem a way to do it. This is obviously a problem others have had.
Have a play on stage.tracks.org.nz around adding new region polygons - try adding a new region and editing an existing one (you should now be able to add regions too BTW). Is this drawing similar to what you would do in Google Earth?
Yes some areas are small, maybe they could be merged later? It might be more obvious if we have this visual view of areas.
I would think that areas wouldn't be inside other areas, maybe this is wrong?
Jonny, 19 Aug 2009 05:30
Cool. I had a play with editing the Area polygons on stage.tracks.org.nz. Seems to work well.
The 'Auto-fit region' function looks intriguing, but what does it do?
I tried to add an area, but it failed with the error message: 'NoMethodError in Region#new'.
I agree that having an area inside another area wouldn't usually make sense, but there might be some circumstances where it does. If so, then the Google Maps polygons can contain holes – as in this example.
Ian, 19 Aug 2009 07:43
The auto-fit just changes the zoom and lat/lng to centre and fit the shape in the window.
Oops that error is a real bug! I will fix asap.
At present my polygons can only have one "path". That pentagon example uses two. If you draw a complicated polygon shape that overlaps itself you get holes. It's a sort of exclusive-or for what's in the shape. Also regions can overlap or be contained right now, however I'm not sure which one would be clickable, possibly the last one that was mouse-over event enabled?
Jonny, 20 Aug 2009 03:47
Should be good now. Stage fixed too.
Jonny, 20 Aug 2009 04:57
That all seems to work well, subject to some tweaks:
In the Stage environment creating a region failed because I gave it the name 'Taranaki (test)' - it didn't like the brackets, I suppose.
When creating a (more reasonably named) region it would help if the other regions' polygons are shown, like they are when editing a region's polygon.
It would be helpful to have a 'Cancel' option in the 'Edit region order' function, in case the user changes their mind or messes it up and wants to try again.
It would also be good to have a 'snap-to' type behaviour so that the vertices of adjacent polygons are nicely aligned. - though that's very much in the nice-to-have category.
Ian, 20 Aug 2009 13:38
Good ideas above. I will investigate the brackets, probably a bug.
I'm not sure how much work for the snap-to feature. The polygon drawing/editing is simple gmap polygon feature. Do you know of an example where snap-to is used?
I had a play with the tooltips. It only works on older versions of the gmap2 spec (2.149), currently 2.172 and 3.11... I am using the mouseOutTolerance feature from a more recent version to make the polygon hover more snappy. I am also looking at one from Bill Chadwick but it's also not so straight forward.
Jonny, 28 Aug 2009 02:35
Yes, tooltips seem to be problematic.
Meanwhile, here's an example of snap-to. The code is obscured and it uses a custom method for drawing polygons which has been superceded by the natice API functionality. In any case, the method seems fairly straightforward, albeit probably involving a fair bit of bruteforce processing.
Ian, 28 Aug 2009 07:46
I think this feature is mostly done. I have created two new features to track the extra items above:
0066 for tooltips
0067 for snap-to
Jonny, 6 Sep 2009 03:42