Skip to content

Commit

Permalink
Map icons now show logo's from cfapi
Browse files Browse the repository at this point in the history
  • Loading branch information
milovanderlinden committed Feb 15, 2018
1 parent 5dc5c04 commit 3a7c96f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7,487 deletions.
5 changes: 5 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,9 @@ figure figcaption {
.navbar {
transition: all .6s ease;
border-bottom: 1px solid rgba(219, 219, 219, 0.5);
}
.leaflet-marker-icon {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 50%;
}
117 changes: 34 additions & 83 deletions assets/js/map.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,44 @@
$(document).ready(function() {

$.getJSON(base_url + "organizations.geojson", function (response){

//$.getJSON(base_url + "organizations.geojson", function (response){
$.getJSON("http://api.codeforamerica.org/api/organizations.geojson", function (response){
$(".mobile-menu").click(function(e){
e.preventDefault();
$(".nav-global-secondary ul").slideToggle();
})
function getIcon(properties){
var icon = {
iconSize: [ 38, 38],
className: 'marker',
iconAnchor: [0,25],
shadowUrl: '/assets/images/white.png',
shadowSize: [ 38, 38],
};
if(properties.logo_url){
icon.iconUrl = properties.logo_url;
return icon;
}

switch (properties.id.toLowerCase()){
case "code-for-nl":
icon.iconUrl = base_url + "images/logo/netherlands.jpg";
return icon;
case "code-for-poland":
icon.iconUrl = base_url + "images/logo/cfpoland.svg";
return icon;
default:
return icon;
}
}

var orgs = response;
var cfallOrgs = [];
orgs.features.forEach(function(org) {

if (org.properties.type.indexOf("Code for All") != -1){
org.properties.icon = {}
org.properties.icon.iconSize = [38, 38]
org.properties.icon['className'] = 'marker'
org.properties.icon['iconAnchor'] = [0, 25]

if (org.properties['name'] == 'Code for America'){
org.properties.icon['iconUrl'] = base_url + "images/cfamerica.png"
}
if (org.properties['name'] == 'Codigo para la Ciudad de Mexico'){
org.properties.icon['iconUrl'] = base_url + "images/labplc.jpeg"
}
if (org.properties['name'] == 'Code for the Caribbean'){
org.properties.icon['iconUrl'] = base_url + "images/cfcaribbean.png"
}
if (org.properties['name'] == 'Code for Africa'){
org.properties.icon['iconUrl'] = base_url + "images/cfafrica.png"
}
if (org.properties['name'] == 'Code for South Africa'){
org.properties.icon['iconUrl'] = base_url + "images/cfsa.png"
}
if (org.properties['name'] == 'Code for Kenya'){
org.properties.icon['iconUrl'] = base_url + "images/cfke.png"
}
if (org.properties['name'] == 'Code for Nigeria'){
org.properties.icon['iconUrl'] = base_url + "images/cfng.png"
}
if (org.properties['name'] == 'Code for Ghana'){
org.properties.icon['iconUrl'] = base_url + "images/cfgh.png"
}
if (org.properties['name'] == 'Code for Ireland'){
org.properties.icon['iconUrl'] = base_url + "images/cfireland.png"
if (org.properties.tags.indexOf("Code for All") != -1){
org.properties.icon = getIcon(org.properties);
if(org.properties.id.toLowerCase() !== 'hacking-monterrey'){
cfallOrgs.push(org);
}
if (org.properties['name'] == 'Code for Germany'){
org.properties.icon['iconUrl'] = base_url + "images/cfgermany.jpeg"
}
if (org.properties['name'] == 'Code for Poland'){
org.properties.icon['iconUrl'] = base_url + "images/cfpoland.svg"
}
if (org.properties['name'] == 'Code for Pakistan'){
org.properties.icon['iconUrl'] = base_url + "images/cfpakistan.png"
}
if (org.properties['name'] == 'Code for Seoul'){
org.properties.icon['iconUrl'] = base_url + "images/cfseoul.png"
}
if (org.properties['name'] == 'Code for Japan'){
org.properties.icon['iconUrl'] = base_url + "images/cfjapan.png"
}
if (org.properties['name'] == 'Code for Australia'){
org.properties.icon['iconUrl'] = base_url + "images/cfaustralia.jpeg"
}
if (org.properties['name'] == 'g0v.tw'){
org.properties.icon['iconUrl'] = base_url + "images/g0v.png"
}
if (org.properties['name'] == 'Codeando México'){
org.properties.icon['iconUrl'] = base_url + "images/cfmexico.png"
}
if (org.properties['name'] == 'Code for Ghana'){
org.properties.icon['iconUrl'] = base_url + "images/ghana.png"
}
if (org.properties['name'] == 'Code for Nigeria'){
org.properties.icon['iconUrl'] = base_url + "images/nigeria.png"
}
if (org.properties['name'] == 'Code for Kenya'){
org.properties.icon['iconUrl'] = base_url + "images/kenya.png"
}
if (org.properties['name'] == 'Code for Africa'){
org.properties.icon['iconUrl'] = base_url + "images/c4africa.png"
}
if (org.properties['name'] == 'Code for Tomorrow'){
org.properties.icon['iconUrl'] = base_url + "images/cftomorrow.png"
}
if (org.properties['name'] == 'CodeNamu(Code for Korea)'){
org.properties.icon['iconUrl'] = base_url + "images/codenamu.png"
}

cfallOrgs.push(org);

}
});

Expand All @@ -109,9 +60,9 @@ $(document).ready(function() {
var map = L.map('map').setView(latlon, zoom);

function iconStyle(feature) {
//if (feature.properties.icon && feature.properties.icon.iconUrl) {
// return {icon: L.icon(feature.properties.icon)};
//}
if (feature.properties.icon && feature.properties.icon.iconUrl) {
return {icon: L.icon(feature.properties.icon)};
}
};

function worldStyle(feature) {
Expand Down
Loading

0 comments on commit 3a7c96f

Please sign in to comment.