Last active
May 16, 2016 15:12
-
-
Save dotspencer/779f5eb6962d01577a78 to your computer and use it in GitHub Desktop.
Forge map shortcode and marker data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"EGI" : { | |
"latLong" : "40.758652, -111.827611", | |
"image" : "/api/forge/images/egi.png", | |
"type" : "egi" | |
}, | |
"INL" : { | |
"latLong" : "43.599897, -112.857449", | |
"image" : "/api/forge/images/inl.png", | |
"type" : "partner" | |
}, | |
"Sandia National Laboratories" : { | |
"latLong" : "32.370085, -104.232081", | |
"image" : "/api/forge/images/sandia.png", | |
"type" : "collaborator" | |
}, | |
"SunEdison" : { | |
"latLong" : "38.754644, -90.466392", | |
"image" : "/api/forge/images/sunedison.png", | |
"type" : "stakeholder" | |
}, | |
"Pacific Northwest" : { | |
"latLong" : "46.345283, -119.278630", | |
"image" : "/api/forge/images/pacific-northwest.png", | |
"type" : "collaborator" | |
}, | |
"MIT" : { | |
"latLong" : "42.360107, -71.094160", | |
"image" : "/api/forge/images/mit.png", | |
"type" : "collaborator" | |
}, | |
"Temple University" : { | |
"latLong" : "39.981454, -75.155039", | |
"image" : "/api/forge/images/temple.png", | |
"type" : "partner" | |
}, | |
"Bureau of Land Management" : { | |
"latLong" : "39.102804, -76.770443", | |
"image" : "/api/forge/images/bureau.png", | |
"type" : "resource" | |
}, | |
"US Department of Energy" : { | |
"latLong" : "38.975518, -77.275425", | |
"image" : "/api/forge/images/us-energy.png", | |
"type" : "funding" | |
}, | |
"USGS" : { | |
"latLong" : "39.859263, -121.654350", | |
"image" : "/api/forge/images/usgs.png", | |
"type" : "resource" | |
}, | |
"B. Barker" : { | |
"latLong" : "39.324940, -122.399103", | |
"image" : "/api/forge/images/barker.png", | |
"type" : "resource" | |
}, | |
"Berkeley Lab" : { | |
"latLong" : "37.872951, -122.245805", | |
"image" : "/api/forge/images/berkeley.png", | |
"type" : "collaborator" | |
}, | |
"Lawrence Livermore Lab" : { | |
"latLong" : "37.647855, -121.159076", | |
"image" : "/api/forge/images/lawrence.png", | |
"type" : "collaborator" | |
}, | |
"GRG" : { | |
"latLong" : "33.761273, -116.312154", | |
"image" : "/api/forge/images/grg.png", | |
"type" : "resource" | |
}, | |
"D. Winkler" : { | |
"latLong" : "38.009283, -107.965214", | |
"image" : "/api/forge/images/winkler.png", | |
"type" : "resource" | |
}, | |
"Los Alamos National Lab" : { | |
"latLong" : "35.844138, -106.287051", | |
"image" : "/api/forge/images/los-alamos.png", | |
"type" : "collaborator" | |
}, | |
"SUTREC" : { | |
"latLong" : "38.158753, -110.618357", | |
"image" : "/api/forge/images/sutrec.png", | |
"type" : "stakeholder" | |
}, | |
"Cyrq" : { | |
"latLong" : "39.962756, -110.984459", | |
"image" : "/api/forge/images/cyrq.png", | |
"type" : "resource" | |
}, | |
"Beaver Utah" : { | |
"latLong" : "38.267180, -112.635117", | |
"image" : "/api/forge/images/beaver-city.png", | |
"type" : "stakeholder" | |
}, | |
"Smithfield" : { | |
"latLong" : "38.174215, -112.248788", | |
"image" : "/api/forge/images/smithfield.png", | |
"type" : "resource" | |
}, | |
"Pacificorp" : { | |
"latLong" : "38.815140, -112.542284", | |
"image" : "/api/forge/images/pacificorp.png", | |
"type" : "stakeholder" | |
}, | |
"USU Engineer" : { | |
"latLong" : "40.092025, -112.433267", | |
"image" : "/api/forge/images/usu-engineer.png", | |
"type" : "stakeholder" | |
}, | |
"Utah Quality" : { | |
"latLong" : "40.821790, -112.897261", | |
"image" : "/api/forge/images/utah-quality.png", | |
"type" : "stakeholder" | |
}, | |
"Utah Trust Lands" : { | |
"latLong" : "41.217655, -111.791987", | |
"image" : "/api/forge/images/utah-trust-lands.png", | |
"type" : "resource" | |
}, | |
"Utah Geological Survey" : { | |
"latLong" : "41.285242, -112.458289", | |
"image" : "/api/forge/images/utah-geological.png", | |
"type" : "resource" | |
}, | |
"Utah Seismograph UUSS" : { | |
"latLong" : "40.879292, -111.986327", | |
"image" : "/api/forge/images/uuss.png", | |
"type" : "resource" | |
}, | |
"Governor's Office " : { | |
"latLong" : "40.865990, -111.665460", | |
"image" : "/api/forge/images/governor-office.png", | |
"type" : "resource" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initialize() { | |
var clicked = false; | |
var mapOptions = { | |
center: new google.maps.LatLng(39.828351, -98.579460), //center: new google.maps.LatLng(38, 6), | |
zoom: 4, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, //mapTypeId: google.maps.MapTypeId.HYBRID, | |
mapTypeControl: false, | |
maxZoom: 9, | |
minZoom: 3, | |
streetViewControl: false | |
}; | |
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); | |
var legend = document.createElement('div'); | |
legend.innerHTML = "<img style='width:300px;' src='/api/forge/legend.png'/>" | |
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(legend); | |
var allowedBounds = new google.maps.LatLngBounds( | |
new google.maps.LatLng(-40, -180), | |
new google.maps.LatLng(60, 180) | |
//64.241710, -102.995539 | |
); | |
var lastValidCenter = map.getCenter(); | |
//jQuery.getJSON( "/wp-content/uploads/2014/05/Research.json", function( json ) { | |
jQuery.getJSON("/api/forge.json", function(json) { | |
var markerArray = []; | |
var infoArray = []; | |
jQuery.each(json, function(index) { | |
var split = json[index].latLong.split(", "); | |
var latLong = new google.maps.LatLng(split[0], split[1]); | |
var info = new google.maps.InfoWindow({ | |
content: "<img class='info-image' src='" + json[index].image + "'>" | |
}); | |
// Pushes logo to array to be preloaded. | |
logos.push(json[index].image); | |
var image = { | |
url: "", | |
size: new google.maps.Size(30, 30), | |
origin: new google.maps.Point(0, 0), | |
anchor: new google.maps.Point(15, 15) | |
}; | |
switch (json[index].type) { | |
case "egi": | |
image.url = '/api/forge/star-small.png'; | |
break; | |
case "stakeholder": | |
image.url = '/api/forge/stakeholder.png'; | |
break; | |
case "collaborator": | |
image.url = '/api/forge/collaborator.png'; | |
break; | |
case "funding": | |
image.url = '/api/forge/funding.png'; | |
break; | |
default: | |
image.url = '/api/forge/partner.png'; | |
} | |
var shape = { | |
coords: [5, 5, 5, 25, 25, 25, 25, 5], | |
type: 'poly' | |
}; | |
// if(json[index].type == "egi"){ | |
// image.size = new google.maps.Size(50, 50); | |
// image.origin = new google.maps.Point(0, 0); | |
// image.anchor = new google.maps.Point(25, 25); | |
// shape = { | |
// coords: [1, 1, 1, 45, 45, 45, 45, 1], | |
// type: 'poly' | |
// }; | |
// } | |
// Smaller star | |
if (json[index].type == "egi") { | |
image.size = new google.maps.Size(36, 36); | |
image.origin = new google.maps.Point(0, 0); | |
image.anchor = new google.maps.Point(18, 18); | |
shape = { | |
coords: [1, 1, 1, 30, 30, 30, 30, 1], | |
type: 'poly' | |
}; | |
} | |
var marker = new google.maps.Marker({ | |
position: latLong, | |
map: map, | |
//animation: google.maps.Animation.DROP, | |
zIndex: 0, | |
icon: image, | |
shape: shape | |
}); | |
if (json[index].type == "egi") { | |
marker.zIndex = google.maps.Marker.MAX_ZINDEX + 1; | |
} | |
markerArray.push(marker); | |
infoArray.push(info); | |
}); | |
function closeAllBoxes() { | |
jQuery.each(infoArray, function(index) { | |
if (infoArray[index]) { | |
infoArray[index].close(); | |
} | |
}); | |
} | |
// Open info when marker is clicked | |
jQuery.each(infoArray, function(index) { | |
google.maps.event.addListener(markerArray[index], 'click', function() { | |
closeAllBoxes(); | |
infoArray[index].open(map, markerArray[index]); | |
}); | |
}); | |
google.maps.event.addListener(map, 'click', function() { | |
closeAllBoxes(); | |
}); | |
}); | |
google.maps.event.addListener(map, 'center_changed', function() { | |
if (allowedBounds.contains(map.getCenter()) || allowedBounds.contains(new google.maps.LatLng(map.getCenter().lat(), 100))) { | |
// still within valid bounds, so save the last valid position | |
lastValidCenter = map.getCenter(); | |
return; | |
} | |
// not valid anymore => return to last valid position | |
map.panTo(lastValidCenter); | |
}); | |
console.log("Start Preload Timeout."); | |
window.setTimeout(function() { | |
preload(); | |
}, 500); | |
} | |
var logos = []; | |
google.maps.event.addDomListener(window, 'load', initialize); | |
// Preloading logos for map. | |
function preload() { | |
for (i = 0; i < logos.length; i++) { | |
jQuery("<img />").attr("src", logos[i]); | |
//console.log("Image " + logos[i] + " preloaded."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#map-canvas{ | |
height: 600px; | |
} | |
.content-container .container{margin: 0;display: inline;} | |
.content-container .row{margin: 0;} | |
.content-container .span12{margin: 0;width: 100%;} | |
.tick{ | |
width: 30px; | |
float: left; | |
} | |
.info-image{ | |
//max-width: 350px !important; | |
//max-height: 100px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment