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

started to work on community map #169

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,29 @@ greyColorDark = "#A0A0A0"
URL = "/about/community"
weight = 2

[[Languages.en.menu.main]]
parent = "About"
name = "Community map"
URL = "/about/map"
weight = 3

[[Languages.en.menu.main]]
parent = "About"
name = "History"
URL = "/about/history"
weight = 3
weight = 4

[[Languages.en.menu.main]]
parent = "About"
name = "Brand"
URL = "/about/brand"
weight = 4
weight = 5

[[Languages.en.menu.main]]
parent = "About"
name = "Credits"
URL = "/about/credits"
weight = 5
weight = 6

# banner
[Languages.en.params.banner]
Expand Down
8 changes: 8 additions & 0 deletions content/about/map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "GRASS GIS community map"
date: 2018-12-29T11:02:05+06:00
layout: "map"
---

### Add your self
To add yourself to the GRASS GIS user map you need to follow [these instructions](https://github.com/OSGeo/grass-website/static/geojson/README.md)
69 changes: 69 additions & 0 deletions static/geojson/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# GRASS GIS map

In this folder you can find geographical data related to GRASS GIS community. The data are provided in GeoJSON format.

## User map

The [user.geojson file](https://github.com/OSGeo/grass-website/static/geojson/user.geojson) contain the position of GRASS GIS users.
The [provider.geojson file](https://github.com/OSGeo/grass-website/static/geojson/provider.geojson) contain the position of any companies,
research center, university providing activities (specially development and courses) related to GRASS GIS.

## Add new record

If you want to add a new record to one of the GeoJSON files you have to ways

### User without Git/Github experience

* You need to create a [Github account](https://github.com/join)
* Sign in and move to https://github.com/OSGeo/grass-website/ repository
* Choose the file to modify into [GeoJSON files](https://github.com/OSGeo/grass-website/static/geojson/)
* Click the pencil button to modify the file
* Add a new feature copying the feature template in the bottom of the page
* When you save the file, select `Create a new branch for this commit and start a pull request.`

### Git/Github advanced user

* Fork the https://github.com/OSGeo/grass-website/ repository
* Create a new branch
* Add a new feature copying the feature template in the bottom of the page
* Commit, push the modified file
* Create a pull request

## Templates

### User

{
"type": "Feature",
"properties": {
"name": "NAME_SURNAME",
"url": "YOUR_URL_NOT_REQUIRED",
"image": "URL_TO_YOUR_IMAGE_NOT_REQUIRED"
},
"geometry": {
"type": "Point",
"coordinates": [
LONGITUDE,
LATITUDE
]
}
}

### Provider

{
"type": "Feature",
"properties": {
"name": "NAME_SURNAME",
"url": "YOUR_URL_NOT_REQUIRED",
"image": "URL_TO_YOUR_IMAGE_NOT_REQUIRED",
"description": "SHORT_DESCRIPTION_YOUR_ACTIVITY_IN_GRASS"
},
"geometry": {
"type": "Point",
"coordinates": [
LONGITUDE,
LATITUDE
]
}
}
21 changes: 21 additions & 0 deletions static/geojson/provider.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Mundialis",
"url": "https://www.mundialis.de/en/",
"image": "https://www.mundialis.de/wordpress/wp-content/uploads/2015/11/mundialis_logo.png",
"description": ""
},
"geometry": {
"type": "Point",
"coordinates": [
7.0968584,
50.7409291
]
}
}
]
}
20 changes: 20 additions & 0 deletions static/geojson/user.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Luca Delucchi",
"url": "http://www.lucadelu.org",
"image": ""
},
"geometry": {
"type": "Point",
"coordinates": [
11.111061573028564,
46.13950796157218
]
}
}
]
}
56 changes: 56 additions & 0 deletions themes/grass/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,62 @@ code{
font-size: 7em;
}

#map{
height: 80vh;
width: 100%;
}

.ol-popup {
position: absolute;
background-color: white;
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
padding: 15px;
border-radius: 10px;
border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
min-width: 280px;
}
.ol-popup:after, .ol-popup:before {
top: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.ol-popup:after {
border-top-color: white;
border-width: 10px;
left: 48px;
margin-left: -10px;
}
.ol-popup:before {
border-top-color: #cccccc;
border-width: 11px;
left: 48px;
margin-left: -11px;
}
.ol-popup-closer {
text-decoration: none;
position: absolute;
top: 2px;
right: 8px;
}
.ol-popup-closer:after {
content: "✖";
}

#popup-content p, #popup-content img {
margin-bottom: 0;
font-size: 20px;
font-weight: bolder;
}

input[type='radio']{
margin-right: 0.5rem;
}

@media (max-width: 576px) {

Expand Down
138 changes: 138 additions & 0 deletions themes/grass/assets/js/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@

(function ($) {
var oldfeat;
var vecturl='/geojson/user.geojson';
var container = document.getElementById('popup');
var content = document.getElementById('popup-content');
var closer = document.getElementById('popup-closer');

/**
* Create an overlay to anchor the popup to the map.
*/
var overlay = new ol.Overlay({
element: container,
autoPan: true,
autoPanAnimation: {
duration: 250
}
});


/**
* Add a click handler to hide the popup.
* @return {boolean} Don't follow the href.
*/
closer.onclick = function() {
overlay.setPosition(undefined);
closer.blur();
if (oldfeat) {
oldfeat.setStyle(defaultStyle);
oldfeat = null;
}
return false;
};

var defaultStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: 4,
fill: new ol.style.Fill({
color: 'rgb(255, 255, 255)'
}),
stroke: new ol.style.Stroke({
color: '#088B36',
width: 2
})
})
});

var highlightStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: 8,
fill: new ol.style.Fill({
color: 'rgb(255, 255, 255)'
}),
stroke: new ol.style.Stroke({
color: '#088B36',
width: 3
})
})
});

var vsource = new ol.source.Vector({
url: vecturl,
format: new ol.format.GeoJSON()
});

var vectorLayer = new ol.layer.Vector({
source: vsource,
style: defaultStyle,
title: 'Users'
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
vectorLayer
],
target: 'map',
overlays: [overlay],
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:3857'),
zoom: 2
})
});
map.on('click', function(evt) {
var coordinate = evt.coordinate;
feat = map.forEachFeatureAtPixel(evt.pixel,
function(feature, vectorLayer) {
return feature
}
)
if (feat) {
feat.setStyle(highlightStyle);
oldfeat = feat;
var mycontent = '<p>';
var userurl = feat.get('url')
var userimage = feat.get('image')
if (userimage) {
mycontent += '<image src="' + userimage + '" width="75px">'
}
if (userurl) {
mycontent += '<a href="' + userurl + '" target="_blank">' + feat.get('name') + '</a></p>';
} else {
mycontent += feat.get('name') + '</p>';
}
var userdesc = feat.get('description')
if (userdesc) {
mycontent += '<p><small>' + userdesc + '</small></p>';
}
content.innerHTML = mycontent
overlay.setPosition(coordinate);
} else {
if (oldfeat) {
oldfeat.setStyle(defaultStyle);
oldfeat = null;
}
}
})
$("input[name='layers']").each( function () {
//console.log($(this)[0]);
$(this)[0].addEventListener('change', function () {
var ingeojson = $(this).val();
vecturl = '/geojson/' + ingeojson + '.geojson'
vsource = new ol.source.Vector({
url: vecturl,
format: new ol.format.GeoJSON(),
});
vectorLayer.setSource(vsource);
vectorLayer.getSource().refresh();
vectorLayer.getSource().changed();
})
});
})(jQuery);
Loading