Created
March 30, 2016 06:37
-
-
Save phpkidindia/a448e9b8132d3634bdebfa70a8d20c03 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
<table id="example" class="display" cellspacing="0" width="100%"> | |
<thead> | |
<tr> | |
<th class="link">Longitude</th> | |
<th>Latitude</th> | |
<th>Location Name</th> | |
<th>Common Name</th> | |
<th>How Many</th> | |
<th>Scientific Name</th> | |
</tr> | |
</thead> | |
<tfoot> | |
<tr> | |
<th class="link">Longitude</th> | |
<th>Latitude</th> | |
<th>Location Name</th> | |
<th>Common Name</th> | |
<th>How Many</th> | |
<th>Scientific Name</th> | |
</tr> | |
</tfoot> | |
</table> | |
$(document).ready(function() { | |
$('#example').dataTable( { | |
"ajax": { | |
"url": "http://ebird.org/ws1.1/data/obs/geo/recent?lng=-112.53&lat=53.38&dist=10&back=30&maxResults=500&locale=en_US&fmt=json", | |
"dataSrc": "" | |
}, | |
"columns": [ | |
{ "data": "lng","class":"lng" }, | |
{ "data": "lat", "class":"lat"}, | |
{ "data": "locName","class":"link" }, | |
{ "data": "comName", }, | |
{ "data": "howMany" }, | |
{ "data": "sciName" } | |
] | |
} ); | |
$('#example tbody').on( 'click', 'td.link', function () { | |
var lng = $(this).prevAll(".lng").text(); | |
var lat = $(this).prevAll(".lat").text(); | |
//var lat = $(this).prev('.lat').text(); | |
var url = 'http://maps.google.ca/maps?f=d&daddr='+lat+','+ lng+ '&z=8'; | |
window.open ( url, '_blank'); | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment