Created
September 17, 2010 11:12
-
-
Save psychemedia/584067 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
<html> | |
<head><title>Static Map Demo</title> | |
</head><body> | |
<?php | |
error_reporting(-1); | |
ini_set('display_errors', 'on'); | |
include("json.php"); | |
// Future-friendly json_encode | |
if( !function_exists('json_encode') ) { | |
function json_encode($data) { | |
$json = new Services_JSON(); | |
return( $json->encode($data) ); | |
} | |
} | |
// Future-friendly json_decode | |
if( !function_exists('json_decode') ) { | |
function json_decode($data) { | |
$json = new Services_JSON(); | |
return( $json->decode($data) ); | |
} | |
} | |
$response = file_get_contents("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.dallaspolice.net%2Fmediaaccess%2FDefault.aspx%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22grdData_ctl01%22%5D%2Ftbody'&format=json"); | |
$json = json_decode($response); | |
$reports = array(); | |
if(isset($json->query->results)) | |
{ | |
$str= "<img src='http://maps.google.com/maps/api/staticmap?center=Dallas,Texas"; | |
$str.="&zoom=10&size=512x512&maptype=roadmap"; | |
$ul="<ul>"; | |
$results = $json->query->results; | |
$i = 0; | |
foreach($results->tbody->tr as $tr) | |
{ | |
$reports[$i]['incident_num'] = $tr->td[1]->p; | |
$reports[$i]['division'] = $tr->td[2]->p; | |
$reports[$i]['nature_of_call'] = $tr->td[3]->p; | |
$reports[$i]['priority'] = $tr->td[4]->p; | |
$reports[$i]['date_time'] = $tr->td[5]->p; | |
$reports[$i]['unit_num'] = $tr->td[6]->p; | |
$reports[$i]['block'] = $tr->td[7]->p; | |
$reports[$i]['location'] = $tr->td[8]->p; | |
$reports[$i]['beat'] = $tr->td[9]->p; | |
$reports[$i]['reporting_area'] = $tr->td[10]->p; | |
$reports[$i]['status'] = $tr->td[11]->p; | |
$addr=$reports[$i]['block']." ".$reports[$i]['location']; | |
$label=chr(65+$i); | |
$str.="&markers=color:blue|label:".$label."|".urlencode($addr); | |
$str.=urlencode(",Dallas,Texas"); | |
$ul.="<li>".$label." - "; | |
$ul.=$reports[$i]['date_time'].": ".$reports[$i]['nature_of_call']; | |
$ul.", incident #".$reports[$i]['incident_num']; | |
$ul.=", unit ".$reports[$i]['unit_num']." ".$reports[$i]['status']; | |
$ul.=" (priority ".$reports[$i]['priority'].") - ".$reports[$i]['block']." ".$reports[$i]['location']; | |
$ul.="</li>"; | |
$i++; | |
} | |
$str.="&sensor=false"; | |
$str.="'/>"; | |
echo $str; | |
$ul.="</ul>"; | |
echo $ul; | |
} | |
//echo json_encode($reports); | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment