-
-
Save jbueza/706928 to your computer and use it in GitHub Desktop.
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
<div id="map_canvas" style="width: 400px; height: 600px"></div> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
// load the data | |
$.getScript('js/store.js', function() { | |
//this gets invoked after store.js loads | |
var myLatlng = new google.maps.LatLng(65.000, 16.500 ); | |
var myOptions = { | |
zoom: 4, | |
center: myLatlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(document.getElementById("map_canvas"), | |
myOptions); | |
console.log('before mapping function'); | |
return function(map) { | |
console.log('inside mapping function and params: ', arguments); | |
var data = $(document.body).data(); | |
$(data.trafikk).each(function(index, value){ | |
var veiX = data.trafikk[index].Coordinates.StartPoint.xCoord; | |
var veiY = data.trafikk[index].Coordinates.StartPoint.yCoord; | |
var veiLatlng = new google.maps.LatLng(veiY, veiX); | |
var marker = new google.maps.Marker({ | |
position: veiLatlng, | |
map: map, | |
title: data.trafikk[index].heading + " - " + data.trafikk[index].messageType | |
}); | |
}); | |
}(map); //execute | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment