Web API Geo Location

Timothy Duffy edited this page Jun 5, 2013 · 4 revisions

Geo Location API's

The Geo Location API returns simple JSON object which can be used with mapping tools such as [Google maps] (https://developers.google.com/maps/documentation/javascript/tutorial) or [leafletjs] (http://leafletjs.com/).

Daily Geo Data Data



  • date - The date of interest (note: if no date is specified, today's date is used.)
  • typeid - This is the ID of the event type you would like geodata on. The list of event type id's can be found using the [Incident Count API] (https://github.com/thequbit/mc911feedwatcher/wiki/Web-API---Incident-Counts). Note: if no typeid is specified, then all of the day's incident data is returned.


  • This API call returns all of the incidents for a single data that have geo location data decoded for them. Note: not all incidents will have geo data. If an incident does not have geo data, it is not returned in this call.

Headers in JSON

  • itemid- The unique Monroe County Incident ID
  • incident - The incident name that occurred at this address.
  • fulladdress - This is the full address of the incident as returned by Google.
  • lat - Latitiude value
  • lng - Longitude value

Response Object:

	"incident":"Hit and Run, no injury and no blocking",
	"fulladdress":"652 Rush West Rush Road, Rush, NY 14543, USA",
	"incident":"Parking complaint",
	"fulladdress":"151 Saint Paul Street, Baltimore, MD 21218, USA",

... etc.


Google Maps Example Implementation

Below is a very simple example of how to use the above described API within Google Maps.

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<div id="map" style="margin: auto; width: 640px; height: 480px;"></div>

<script type="text/javascript">

	var map = new google.maps.Map(document.getElementById('map'), {
		zoom: 10,
		center: new google.maps.LatLng(43.1547, -77.6158),
		mapTypeId: google.maps.MapTypeId.ROADMAP

	function loadData()
		// get all of the incidents for today
		var url = "http://mcsafetyfeed.org/api/getgeo.php";
		$.getJSON(url, function (response) {handleData(response)});

	function handleData(response)
		// for each incident, place a marker on the map
		var n;
		for(n=0; n<response.length; n++)
			lat = response[n].lat;
			lng = response[n].lng;
			event = response[n].event;
			var myLatLng = new google.maps.LatLng(lat,lng);
			var marker = new google.maps.Marker({
				position: myLatLng,
				//shadow: shadow,
				map: map,
				title: event,
				zIndex: 1

	// load the markers on the map


The above code example will produce a google map object that is center on the screen and is 640x480 pixels large. It will hold all of the incidents of the current day on it.