<!DOCTYPE html>
<html>
	<head>
		<title>Map Tests</title>
	</head>
	<body>
		<h1>Map Tests</h1>
		<?php 
include_once "../includer.php";
$map = new Map(null);
echo "Map ID: " . $map->getMapID();
echo "<hr/>";
echo "<h3>Should add three locations to map and print</h3>";
$map->addLocation("New York");
$map->addLocation("London");
$map->addLocation("Rome");
foreach ($map->getLocations() as $location) {
    echo "<h4>{$location}</h4>";
}
echo "<hr/>";
echo "<h3>Should remove last location and print remaining</h3>";
$map->removeLastLocation();
foreach ($map->getLocations() as $location) {
    echo "<h4>{$location}</h4>";
}
echo "<hr/>";
?>
	</body>
</html>
<!DOCTYPE html>
<html>
	<head>
		<title>MapView Tests</title>
	</head>
	<body>
		<h1>MapView Tests</h1>
		<h3>Should call MapView::show()</h3>
		<hr/>
		<?php 
include_once "../includer.php";
$map = new Map(null);
$map->addLocation("Rome");
MapView::show($map->getLocations());
?>
	</body>
</html>
예제 #3
0
<?php

header('Access-Control-Allow-Origin: http://localhost:63342/alertt_app/map.html');
class Map
{
    public function connectDB($sql)
    {
        $conn = new mysqli("localhost", "root", "root", "alertt_db");
        $conn->query($sql);
        $conn->close();
    }
    public function addLocation()
    {
        $hazard = filter_input(INPUT_POST, 'hazard');
        $comment = filter_input(INPUT_POST, 'comment');
        $lat = filter_input(INPUT_POST, 'lat');
        $lng = filter_input(INPUT_POST, 'lng');
        $SQL = 'INSERT INTO hazards_tb (hazard, comment,lat,lng) VALUES ("' . $hazard . '","' . $comment . '","' . $lat . '","' . $lng . '")';
        $this->connectDB($SQL);
    }
}
$map = new Map();
echo $map->addLocation();