Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gluon-config-mode-geo-location-osm: OpenStreetMap-based location picker #1515

Merged
merged 7 commits into from
Sep 1, 2018

Conversation

neocturne
Copy link
Member

This PR contains the revised version of the OpenStreetMap-based location picker for the config mode (#1484).

Changes:

  • Better integration with gluon-web
  • OpenLayers 5 (instead of 2)
  • Lots of changed strings (both package names and user-visible texts)
  • Extend gluon-config-mode-geo-location rather than replacing it (avoiding to build multiple variants of the same code)

The one big remaining issue is that OpenLayers 5.1.3 does not work with XHTML (or HTML5 delivered with application/xhtml+xml Content-Type). This has been fixed in openlayers/openlayers#8524, so I hope the next OpenLayers release will just work.

@neocturne neocturne added 0. type: enhancement The changeset is an enhancement 2. status: blocked Marked as blocked because it's waiting on something labels Aug 19, 2018
@neocturne neocturne force-pushed the geo-location-osm branch 2 times, most recently from 50e6502 to a2913e1 Compare August 19, 2018 20:08
@rotanid rotanid added this to the 2018.2 milestone Aug 20, 2018
@@ -407,6 +407,13 @@ config_mode \: optional
package. Set *geo_location.show_altitude* to *true* if you want the altitude
field to be visible.

The *geo_location.osm* section is only relevant when the *gluoin-config-mode-geo-location-osm*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gluoin-config-mode-geo-location-osm -> gluon-config-mode-geo-location-osm

@@ -0,0 +1,4 @@
need_number(in_site({'config_mode', 'geo_location', 'osm', 'center', 'lon'}))
need_number(in_site({'config_mode', 'geo_location', 'osm', 'center', 'lat'}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can have default values like 0.0/0.0 to reduce site.conf parameters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly not. This is a value that must be provided by each site, 0.0/0.0 simply doesn't make sense.

@@ -284,6 +284,12 @@ code {
margin-bottom: 2em;
}

.gluon-osm-map {
width: 100%;
height: 40em;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

40em seems to much maybe 25 is better the map looks nicer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The width of the main content scales between 40em and 60em (depending on the window width), meaning that with a height of 40em the map is square in narrow windows, and has a 3:2 aspect ratio in wide windows. This is already close to the usual widescreen display aspect ratio of 16:10.

Given that the relevant areas for sites should be circular on average, a square seems like the best approximation to me. Further decreasing the height would make the map less square, so we should either increase the height, or keep the current value...

@neocturne
Copy link
Member Author

Screenshot:

image

@rotanid
Copy link
Member

rotanid commented Aug 22, 2018

i think it's a nice solution.
btw., the fix to openlayers was merged.

if osm then
map = s:option(osm.MapValue, "map", osm.options(lon, lat))
map:depends(share_location, true)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more clear if we put the 'share_location' checkbox below the map.

@mweinelt
Copy link
Contributor

mweinelt commented Aug 23, 2018

This would be an ideal basis for picking a domain, e.g. through boundary box overlays, like at https://darmstadt.freifunk.net/mitmachen/domains/.

@2tata
Copy link
Contributor

2tata commented Aug 24, 2018

@NeoRaider There seems a bug in thins code. If I have "Advertise node position" checked and had already select a position on the map. After Pressing "Save & restart" the configmode will be just reload but not completed. Only after I have unchecked "Advertise node position" I can apply the formula.

@neocturne
Copy link
Member Author

Hmm, I will look into this.

@neocturne neocturne force-pushed the geo-location-osm branch 2 times, most recently from 14822d7 to 3bd2078 Compare August 24, 2018 18:17
@neocturne
Copy link
Member Author

I fixed two issues in the code:

  • missing validate() override
  • map was not using the previously submitted lon/lat values when form was rejected because of unrelated validation failures

@2tata
Copy link
Contributor

2tata commented Aug 26, 2018

@NeoRaider I can confirm the bugfix. Now everything seems working as expected.

define the default center of the map when no position has been picked yet. The *zoom* level
defaults to 12 in this case. *openlayers_url* allows to override the base URL of the
*build/ol.js* and *css/ol.css* files (the default is
``https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.1.3``).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url can be update to https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.2.0/build/ol.js
that contains your upstream fixes.

Can be used for inserting Lua values into inline JS code.
The new code is shorter and uses more readable variable names. It does not
depend on specifically named input fields anymore (allowing to use multiple
maps on the same page), and only uses well-defined interfaces to trigger
revalidation of input fields.

The Map model class allows to add OSM maps to gluon-web forms.
gluon-config-mode-geo-location-osm extends the
gluon-config-mode-geo-location with a location picker based on
OpenStreetMaps.

Based-on-patch-by: Jan-Tarek Butt <tarek@ring0.de>
@neocturne neocturne merged commit a8d736a into master Sep 1, 2018
@neocturne neocturne deleted the geo-location-osm branch September 1, 2018 09:39
@rubo77
Copy link
Contributor

rubo77 commented Sep 6, 2018

worth noting: the URL in the example from site.rst does not work. That is just an example from alpha centauri, if you are mirroring the javascript in your own domain.

docs/user/site.rst sais:

openlayers_url allows to override the base URL of the build/ol.js and css/ol.css files (the default is https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.2.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. type: enhancement The changeset is an enhancement 2. status: blocked Marked as blocked because it's waiting on something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants