Using the Roadkill API to add a Google Map to your webpage

UPDATE: This demonstration is for Google Maps Javascript API Version 2. Directions are now available for using Google Maps Javascript API Version 3 with the Roadkills Controller in the IFWIS Core API.

Are you concerned about roadkill?  Would you like to display current roadkill information on your website or blog?  Now you can using the Roadkills Controller in the Core API.  Here's how in three easy steps.


STEP 1. Configure the URL to request

Visit and design your query using the editor.  For example, you may just be interested in one Highway section such as the first 22 miles of Highway 21.

Stripped of the empty parameters your url should now resemble:

Now, we can add some special parameters to grab the most recent observations.  Add to your url the following &start=-730&end=now to limit your results to the last two years of observations.  The -730 is the number of days before the current date and time to include.  You may tailor this to your needs.  You can of course also use full dates, but this allows your query to be dynamic and useful in the future.

Possible parameters for date fields Observed Date (start, end) and Reported or iNsert Date (nstart, nend) include:

  • Valid dates in the format 1/10/2008
  • Now - current system datetime in Mountain Standard Time
  • Today - current day in Mountain Standard Time
  • Yesterday - previous day in Mountain Standard Time
  • Integer - positive or negative offset in days

Finally, add the kml extension, by copying the path from the kml icon or copying the following:


STEP 2: Add the Code

<script type="text/javascript" src="{YOUR GOOGLE MAPS API KEY}">
   <script src="" type="text/javascript"></script>
   <script type="text/javascript">

       google.load("jquery", "1.4.2");
       google.load("maps", "2", {
           other_params: "sensor=false"

       google.setOnLoadCallback(function () {

       var map;
       var geoXml;

       function initializemaps() {
           if (GBrowserIsCompatible()) {
               geoXml = new GGeoXml("" + parseInt(Math.random() * 99999999, 10));
               map = new GMap2(document.getElementById("map_canvas"));
               map.setCenter(new GLatLng(43.58, -116.06), 12);

    <div id="map_canvas" style="width: 550px; height: 600px; float:left; border: 1px solid black;">Loading...</div>

Couple small configuration notes:

  • If you are putting this online you'll need to replace {YOUR GOOGLE MAPS API KEY} with your own where indicated above.  If you don't already have one, visit (don't worry they're free!).
  • The URL you built in Step 1 may be different, edit the following with your url.  Keep the final cachebuster part as it'll keep your data current.
    geoXml = new GGeoXml("" + parseInt(Math.random() * 99999999, 10));
  • Change the zoom center and zoom level by modifying this line appropriately:
    map.setCenter(new GLatLng(43.58, -116.06), 12);
  • You may not have full access to HTML behind your pages (for example in a blog).  Simply add the <div> section and then past the <script> sections afterwards.  If you already have jquery or google maps loaded you may skip these sections.


Result:  View a Live Demo
Below is a static image because GMaps Ver. 2 does not support HTTPS. Click here to see and download a live demo. An HTTPS GMaps Ver. 3 demo is also available.

Example Output

STEP 3: Enjoy

That's it!  This page you have created will update itself as new observations are added to the Roadkill page.