police data/crimes

pd i work with is wanting to have a map of the city and tie incidents to certain addresses to certain crimes.
they want it free.
haha
we don't have gis but the county we reside in has gis and said they are willing to help.
any solutions you know that is free or cheap.
if so.
how do i populate the map with info of addresses...

jamesmetcalf74Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
There are a lot of moving parts to your question, and the "free" part does not make sense - this is likely to require considerable programming.

Please see the page here, where I populate a map with the markers showing where clients come from.  
http://www.landonbaseball.com/site_visitors.php

You need some way to translate the crime information from an address into a lat-lon pair.  This is called a geocoder.  Google it, and you will have many learning resources.  For my page, the lat/lon information comes from my data base.  The data base is populated by information I get from geoio.com - a service that takes an IP address and returns the geographic information associated with it.

So in general terms the steps would go something like this...

To build your data base: Get crime data.  Geocode the location of the crime.  Store crime and geocode in data base.
To report your data base: Select crime and geocode from data base.  Use a mapping service to draw the maps with the crime markers.

HTH, ~Ray
<?php // landonbaseball.com/site_visitors.php

require_once('_head.php');

// OUR SURROUNDING AREA WITH LAT,LON
// Poolesville 39.145939,-77.416931
// Jessup      39.149275,-76.775249
// Manassas    38.750949,-77.475267
// Croom, MD   38.752500,-76.764167
// TRANSLATED INTO LIMITS FOR THE SELECTION
$lo_lat = '38.7000';
$hi_lat = '39.2000';
$lo_lon = '-77.5000';
$hi_lon = '-76.7000';

// HOW MANY MARKERS CAN WE PRODUCE?
$lim = 25;

// GET A COUNT OF UNIQUE LOCATIONS
$sql = "SELECT _key FROM visitors";
$res = mysql_query($sql);
if (!$res) die( mysql_error() );
$num = mysql_num_rows($res);
$num = number_format($num);
?>

<h3>LandonBaseball.com</h3>
<p>... was recently visited by <?php echo $num; ?> folks from these unique locations: <img style="display:inline; margin:0; paddding:0;" src="ikons/orange_google_pointer.png" /></p>

<?php

// MAKE A GOOGLE STATIC MAP OBJECT
$gsm = new GSM;

// DRAW THE LOCAL MAP
$gsm->setWidth(620);
$gsm->setHeight(400);
$gsm->setZoom(10);

// SET A CENTER POINT
$gsm->setCenter("Landon School, Bethesda, MD");

// GET THE LAT/LON PAIRS AND SET THE MARKERS
$sql = "SELECT lat, lon FROM visitors  WHERE  ( (lat BETWEEN $lo_lat AND $hi_lat) AND (lon BETWEEN $lo_lon AND $hi_lon) ) ORDER BY dov DESC LIMIT $lim";
$res = mysql_query($sql);
if (!$res) die( mysql_error() );
while ($row = mysql_fetch_assoc($res))
{
    $lat = $row["lat"];
    $lon = $row["lon"];
    // SET A MARKER ICON BY GEOCODE (LAT/LON PAIR)
	$gsm->setMarker("$lat,$lon", 'orange', 'small', NULL);
}

// SET LANDON ICON LAST (S/B ON TOP OF OTHER MARKERS)
$gsm->setIcon("Landon School, Bethesda, MD", 'http://www.landonbaseball.com/ikons/L32_brown.png');

// ECHO THE <img /> TAG INTO OUR HTML TO DRAW THE MAP
echo $gsm->asIMG();
echo "<br/>" . PHP_EOL;

// END OF JOB
require_once('foot.php');
die();


// DEFINE THE GOOGLE STATIC MAPPING CLASS
class GSM
{
    // THE MAP CENTER GEOCODE, ADDRESS OR LANDMARK
    protected $center;

    // MARKER DATA ARRAY
    protected $markers;
    protected $default_icon;

    // OUR VARIABLES FOR THE MAP DISPLAY
    protected $maptype;
    protected $width;
    protected $height;
    protected $zoom;
    protected $format;

    // OUR VARIABLES FOR THE GOOGLE URL AND IMAGE TAG
    protected $alt;
    protected $title;
    protected $class;
    protected $id;
    protected $usemap;
    protected $sensor;
    protected $url;
    private $img;

    // A CONSTRUCTOR TO SET THE DEFAULT VALUES
    public function __construct()
    {
        // THE URL AND IMG TAG PARAMETERS
        $this->alt    = FALSE;
        $this->class  = FALSE;
        $this->id     = FALSE;
        $this->usemap = FALSE;
        $this->sensor = FALSE;
        $this->title  = TRUE;
        $this->url    = '';
        $this->img    = '';

        // THE CENTER AND ZOOM SCALE OF THE MAP (IF OMITTED, GOOGLE WILL CALCULATE)
        $this->center  = NULL;
        $this->zoom    = NULL;

        // THE CHARACTERISTICS OF THE MAP IMAGE
        $this->maptype = 'hybrid';    // CHOOSE
        $this->maptype = 'terrain';   // AMONG
        $this->maptype = 'satellite'; // THESE
        $this->maptype = 'roadmap';   // OPTIONS
        $this->width   = '640';
        $this->height  = '640';
        $this->format  = 'png';

        // THE DEFAULT ICON
        $this->default_icon = 'http://maps.google.com/mapfiles/ms/micons/question.png';

        // AN ARRAY OF MARKER ARRAYS
        $this->clearMarkers();

    } // END CONSTRUCTOR

    // A METHOD TO CLEAR THE MARKERS
    public function clearMarkers()
    {
        $this->markers = array();
    }

    // A SETTER TO ADD MARKERS TO THE MAP
    public function setMarker($geocode, $color='blue', $size='normal', $label='X')
    {
        $this->markers[]
        = array
        ( 'color'   => $color
        , 'label'   => $label
        , 'geocode' => $geocode
        , 'size'    => $size
        , 'icon'    => FALSE
        )
        ;
    }

    // A SETTER TO ADD ICONS TO THE MAP - VIEW SOURCE HERE: http://www.visual-case.it/cgi-bin/vc/GMapsIcons.pl
    public function setIcon($geocode, $icon=FALSE)
    {
        if (!$icon) $icon = $this->default_icon;
        $this->markers[]
        = array
        ( 'color'   => FALSE
        , 'label'   => FALSE
        , 'geocode' => $geocode
        , 'icon'    => $icon
        )
        ;
    }

    // A SETTER TO OVERRIDE EACH OF THE DEFAULT VALUES
    public function setCenter($geocode=NULL)
    {
        $this->center = $geocode;
    }
    public function setMaptype($x)
    {
        $this->maptype = $x;
    }
    public function setFormat($x)
    {
        $this->format = $x;
    }
    public function setWidth($x)
    {
        $this->width = $x;
    }
    public function setHeight($x)
    {
        $this->height = $x;
    }
    public function setZoom($x=NULL)
    {
        $this->zoom = $x;
    }
    public function setAlt($x=FALSE)
    {
        $this->alt = $x;
    }
    public function setTitle($x=TRUE)
    {
        $this->title = $x;
    }
    public function setClass($x=FALSE)
    {
        $this->class = $x;
    }
    public function setId($x=FALSE)
    {
        $this->id = $x;
    }
    public function setUsemap($x=FALSE)
    {
        $this->usemap = $x;
    }
    public function setSensor($x=FALSE)
    {
        $this->sensor = $x;
    }

    // A METHOD TO PREPARE AND RETRIEVE THE MAPPING URL
    public function asURL()
    {
        $s = 'false'; // SEE http://code.google.com/apis/maps/documentation/staticmaps/#Sensor
        if ($this->sensor) $s = 'true';

        // IF ICONS OR MARKERS ARE ON THE MAP, 'IMPLODE' THE DATA INTO THE URL
        $marker_string = '';
        foreach ($this->markers as $marker)
        {
            // PROCESS FOR CUSTOM ICONS
            if ($marker['icon'])
            {
                $marker_string
                = $marker_string
                . '&markers='
                . 'icon:'
                . urlencode($marker['icon'])
                . '|'
                . $marker['geocode']
                ;
                continue;
            }
            // PROCESS FOR STANDARD MARKERS
            $marker_string
            = $marker_string
            . '&markers='
            . 'color:'
            . $marker['color']
            . '|'
            . 'label:'
            . $marker['label']
            . '|'
            . 'size:'
            . $marker['size']
            . '|'
            . $marker['geocode']
            ;
        }

        // SET CENTER AND ZOOM, IF PRESENT
        $c = '';
        if ($this->center) $c = "&center=$this->center";
        $z = '';
        if ($this->zoom)   $z = "&zoom=$this->zoom";

        // MAKE THE URL
        $this->url
        = "http://maps.google.com/maps/api/staticmap?sensor=$s"
        . $c
        . $z
        . "&size=$this->width" . 'x' . "$this->height"
        . "&format=$this->format"
        . "&maptype=$this->maptype"
        . "$marker_string"
        ;
        return $this->url;
    }

    // A METHOD TO PREPARE AND RETRIEVE THE HTML IMAGE TAG
    public function asIMG()
    {
        // GET THE URL
        if (!$this->url) $this->url = $this->asURL();

        // GET THE ALT TEXT
        $a = "$this->maptype" . ' centered ' . "$this->center";
        if ($this->alt !== FALSE) $a = $this->alt;

        // REQUIRED FIELDS
        $this->img = '<img src="' . $this->url . '" alt="' . $a . '"';

        // OPTIONAL FIELDS - PROVIDE A DEFAULT TITLE
        $t = "$this->maptype" . ' centered ' . "$this->center";
        if     ($this->title  === TRUE ) { $this->img .= ' title="' . $t .           '"'; }
        elseif ($this->title !== FALSE)  { $this->img .= ' title="' . $this->title . '"'; }

        // OPTIONAL FIELDS MAY BE OMITTED
        if ($this->class  !== FALSE) { $this->img .= ' class="'  . $this->class  . '"'; }
        if ($this->id     !== FALSE) { $this->img .= ' id="'     . $this->id     . '"'; }
        if ($this->usemap !== FALSE) { $this->img .= ' usemap="' . $this->usemap . '"'; }

        // CLOSE THE IMAGE TAG AND CLEAR THE CONSUMED URL
        $this->img .= ' />';
        $this->url = FALSE;
        return $this->img;
    }
} // END CLASS

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jcimarronCommented:
jamesmetcalf74--Perhaps of help
http://www.neighborhoodscout.com/neighborhoods/crime-rates/
Many cities have their own websites showing where crimes occur.  You say you have contacted your local police dept. That sounds like a good idea.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.