Skip to content

Commit

Permalink
Integrates Open Streets Map option into the web app (fossasia#2107) (f…
Browse files Browse the repository at this point in the history
…ossasia#2122)

* Integrates Open Streets Map option into the web app (fossasia#2107)

* minor bug fix
  • Loading branch information
Introwitt authored and mariobehling committed Dec 9, 2018
1 parent c43e5c4 commit 570882c
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 105 deletions.
1 change: 1 addition & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
"eslint": "^4.19.1",
"husky": "^0.14.3"
}
}
}
230 changes: 132 additions & 98 deletions src/backend/assets/js/map.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,144 @@
let initMap = function () {

let mapword = document.getElementById('mappos').value;
let maparray = mapword.split(',');
let latitude = parseFloat(maparray[0]);
let longitude = parseFloat(maparray[1]);
let myLatLng = {lat: latitude, lng:longitude};
let myLngLat = {lng: longitude, lat:latitude};
let map;
const theme = parseInt(document.getElementById('theme').value);

if(theme)
let googleMarker;
let osmMarker;
const theme = parseInt(document.getElementById('theme').value);
const mapType = parseInt(document.getElementById('mapType').value);

// Selects the type of map - OSM OR Google maps
if(mapType)
{
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: myLatLng,
styles: [
{elementType: 'geometry', stylers: [{color: '#242f3e'}]},
{elementType: 'labels.text.stroke', stylers: [{color: '#242f3e'}]},
{elementType: 'labels.text.fill', stylers: [{color: '#746855'}]},
{
featureType: 'administrative.locality',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi.park',
elementType: 'geometry',
stylers: [{color: '#263c3f'}]
},
{
featureType: 'poi.park',
elementType: 'labels.text.fill',
stylers: [{color: '#6b9a76'}]
},
{
featureType: 'road',
elementType: 'geometry',
stylers: [{color: '#38414e'}]
},
{
featureType: 'road',
elementType: 'geometry.stroke',
stylers: [{color: '#212a37'}]
},
{
featureType: 'road',
elementType: 'labels.text.fill',
stylers: [{color: '#9ca5b3'}]
if(theme){
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: myLatLng,
styles: [
{elementType: 'geometry', stylers: [{color: '#242f3e'}]},
{elementType: 'labels.text.stroke', stylers: [{color: '#242f3e'}]},
{elementType: 'labels.text.fill', stylers: [{color: '#746855'}]},
{
featureType: 'administrative.locality',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'poi.park',
elementType: 'geometry',
stylers: [{color: '#263c3f'}]
},
{
featureType: 'poi.park',
elementType: 'labels.text.fill',
stylers: [{color: '#6b9a76'}]
},
{
featureType: 'road',
elementType: 'geometry',
stylers: [{color: '#38414e'}]
},
{
featureType: 'road',
elementType: 'geometry.stroke',
stylers: [{color: '#212a37'}]
},
{
featureType: 'road',
elementType: 'labels.text.fill',
stylers: [{color: '#9ca5b3'}]
},
{
featureType: 'road.highway',
elementType: 'geometry',
stylers: [{color: '#746855'}]
},
{
featureType: 'road.highway',
elementType: 'geometry.stroke',
stylers: [{color: '#1f2835'}]
},
{
featureType: 'road.highway',
elementType: 'labels.text.fill',
stylers: [{color: '#f3d19c'}]
},
{
featureType: 'transit',
elementType: 'geometry',
stylers: [{color: '#2f3948'}]
},
{
featureType: 'transit.station',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'water',
elementType: 'geometry',
stylers: [{color: '#17263c'}]
},
{
featureType: 'water',
elementType: 'labels.text.fill',
stylers: [{color: '#515c6d'}]
},
{
featureType: 'road.highway',
elementType: 'geometry',
stylers: [{color: '#746855'}]
},
{
featureType: 'road.highway',
elementType: 'geometry.stroke',
stylers: [{color: '#1f2835'}]
},
{
featureType: 'road.highway',
elementType: 'labels.text.fill',
stylers: [{color: '#f3d19c'}]
},
{
featureType: 'transit',
elementType: 'geometry',
stylers: [{color: '#2f3948'}]
},
{
featureType: 'transit.station',
elementType: 'labels.text.fill',
stylers: [{color: '#d59563'}]
},
{
featureType: 'water',
elementType: 'geometry',
stylers: [{color: '#17263c'}]
},
{
featureType: 'water',
elementType: 'labels.text.fill',
stylers: [{color: '#515c6d'}]
},
{
featureType: 'water',
elementType: 'labels.text.stroke',
stylers: [{color: '#17263c'}]
}
]
});
}
else{
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: myLatLng
featureType: 'water',
elementType: 'labels.text.stroke',
stylers: [{color: '#17263c'}]
}
]
});
} else{
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: myLatLng
});
}

googleMarker = new google.maps.Marker({
position: myLatLng,
map: map
});
}

let marker = new google.maps.Marker({
position: myLatLng,
map: map
});
};
} else{

mapboxgl.accessToken = 'pk.eyJ1IjoiaGFyc2hrYXNoeWFwIiwiYSI6ImNqbjc0ZGRpcDAxZGIzcHA4MHduN3dkdDgifQ.YO4DvPlp5O7VTvlB0K4d0Q';

if(theme){
map = new mapboxgl.Map({
container: 'map',
zoom: 16,
center : myLngLat,
scrollZoom : false,
style: 'mapbox://styles/mapbox/navigation-preview-night-v4'
});
} else{
map = new mapboxgl.Map({
container: 'map',
zoom: 16,
center : myLngLat,
scrollZoom : false,
// style: 'mapbox://styles/mapbox/streets-v10'
style: 'mapbox://styles/mapbox/navigation-preview-day-v4'
});
}

window.initMap = initMap;
osmMarker = new mapboxgl.Marker()
.setLngLat(myLngLat)
.addTo(map);

var nav = new mapboxgl.NavigationControl();
map.addControl(nav, 'bottom-right');
map.addControl(new mapboxgl.FullscreenControl());
}
9 changes: 7 additions & 2 deletions src/backend/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,7 @@ exports.createDistDir = function(req, socket, callback) {
}
logger.addLog('Info', 'Compiling the html pages from the templates', socket);

const jsonData = data;

const jsonData = data;
eventName = fold.removeSpace(jsonData.eventurls.name);
const backPath = distHelper.distPath + '/' + appFolder + '/' + jsonData.eventurls.background_path;
const basePath = distHelper.distPath + '/' + appFolder + '/images';
Expand All @@ -561,6 +560,12 @@ exports.createDistDir = function(req, socket, callback) {
jsonData.theme = 1;
}

if (req.body.map === 'googleMap') {
jsonData.map = 1;
} else {
jsonData.map = 0;
}

if (req.body.ganalyticsID) {
jsonData.ganalyticsID = req.body.ganalyticsID;
}
Expand Down
13 changes: 9 additions & 4 deletions src/backend/templates/event.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="preload" as="style" href="./css/bootstrap.min.css">
<link rel="manifest" href="./manifest.json">
<link rel="preload" as="font" href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,300" crossorigin>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -31,6 +31,10 @@
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/schedule.css">

<!-- Mapbox GL JS Javascript and CSS files for OSM-->
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.50.0/mapbox-gl.js" type="text/javascript"></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.50.0/mapbox-gl.css' rel='stylesheet' />

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
Expand Down Expand Up @@ -208,7 +212,7 @@
</div>
{{/if}}

{{#if eventurls.latitude }}
{{#if eventurls.latitude}}
{{#if eventurls.longitude}}
<div class="location">
<div class="location-map row">
Expand All @@ -233,13 +237,14 @@

<input type="hidden" id="mappos" value="{{{eventurls.latitude}}},{{{eventurls.longitude}}}"/>
<input type="hidden" id="theme" value={{theme}} />

<input type="hidden" id="mapType" value={{map}} />

{{> footer}}

<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js" type="text/javascript"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCd_L2ncYmf3Yyr6Or01E_ze6QEv289HYs" type="text/javascript"></script>
<script type="text/javascript" src="./js/event.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCd_L2ncYmf3Yyr6Or01E_ze6QEv289HYs&callback=initMap" type="text/javascript"></script>
<!--<script src="//platform.twitter.com/widgets.js" charset="utf-8"></script>-->

<script>
Expand Down
19 changes: 19 additions & 0 deletions src/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,24 @@
<label for="expandable">Expandable</label>
</li>
</ul>


<!-- Map Integration-->
<label>Choose Map Integration</label>

<ul style="list-style-type:none;postion: relative;">
<li>
<input id="google" name="map" type="radio" value="googleMap">
<label for="google">Google_Map</label>
</li>

<li>
<input id="open_street" name="map" type="radio" value="openStreetMap">
<label for="open_street">Open_Street_Map</label>
</li>
</ul>


<label>Choose your API version</label>
<ul style="list-style-type:none">
<!--<li><input type="radio" name="datasource" value="mockjson"> Default mock API </input></li>-->
Expand All @@ -315,6 +333,7 @@
<label for="version2">API_v2</label>
</li>
</ul>

<!-- changes-2 added till here -->
<label>Choose your data source</label>
<ul style="list-style-type:none">
Expand Down
3 changes: 3 additions & 0 deletions src/www/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ function getData(initValue) {
if (field.name === 'apiVersion') {
data.apiVersion = field.value;
}
if (field.name === 'map') {
data.map = field.value;
}
});
if ($('#upload-ftp').prop('checked')) {
data.ftpdetails = {
Expand Down

0 comments on commit 570882c

Please sign in to comment.