Skip to content

Instantly share code, notes, and snippets.

@selenamarie
Forked from max-mapper/nike-factories.html
Created March 6, 2011 00:33
Show Gist options
  • Save selenamarie/856880 to your computer and use it in GitHub Desktop.
Save selenamarie/856880 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GeoJSON to Google Maps</title>
<style type="text/css">
#left{
width: 100%;
height: 500px;
float:left;
}
#map{
height:100%;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://github.com/JasonSanford/GeoJSON-to-Google-Maps/raw/master/GeoJSON.js"></script>
<script type="text/javascript">
$(function(){
var map;
currentFeature_or_Features = null;
map = new google.maps.Map(document.getElementById('map'),{
zoom: 2,
center: new google.maps.LatLng(19.808054128088585, 119.53125),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
function fetchFactories(callback) {
$.ajax({
url: "http://api.scraperwiki.com/api/1.0/datastore/getdata?&name=nike_contract_factory_disclosure_list",
dataType: 'jsonp',
success: callback
});
}
function showFactories(data) {
var features = $.map(data, function ( afeature, i ) {
if (afeature.lat) {
return {
"type": "Point",
"coordinates": [
afeature.lng,
afeature.lat
]
}
}})
showFeatures(features, addressStyle);
}
fetchFactories(showFactories);
var addressStyle = {
icon: "https://github.com/JasonSanford/GeoJSON-to-Google-Maps/raw/master/img/marker-house.png"
};
function showFeatures(features, style) {
$.each(features, function(i, feature) {
var gFeature = new GeoJSON(feature, style);
gFeature.setMap(map);
})
}
})
</script>
</head>
<body>
<div id="left">
<div id="map"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment