Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Created March 6, 2011 00:31
Show Gist options
  • Save max-mapper/856879 to your computer and use it in GitHub Desktop.
Save max-mapper/856879 to your computer and use it in GitHub Desktop.
nike factories
<!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