| 1 |
<?
|
| 2 |
/*
|
| 3 |
* Created on 4 déc. 2005
|
| 4 |
*/
|
| 5 |
function htmlentities2unicodeentities($input) {
|
| 6 |
$htmlEntities = array_values(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES));
|
| 7 |
$entitiesDecoded = array_keys(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES));
|
| 8 |
$num = count($entitiesDecoded);
|
| 9 |
for ($u = 0; $u < $num; $u ++) {
|
| 10 |
$utf8Entities[$u] = '&#'.ord($entitiesDecoded[$u]).';';
|
| 11 |
}
|
| 12 |
return str_replace($htmlEntities, $utf8Entities, htmlentities(utf8_decode($input)));
|
| 13 |
}
|
| 14 |
|
| 15 |
class GoogleMap {
|
| 16 |
var $dataarray = array ();
|
| 17 |
|
| 18 |
var $Xmin;
|
| 19 |
var $Xmax;
|
| 20 |
var $Ymin;
|
| 21 |
var $Ymax;
|
| 22 |
var $zlevel;
|
| 23 |
|
| 24 |
var $xclicked;
|
| 25 |
var $yclicked;
|
| 26 |
var $idclicked;
|
| 27 |
|
| 28 |
var $mapaction;
|
| 29 |
|
| 30 |
function echoXMLPoint($pointtag, $point) {
|
| 31 |
echo "<".$pointtag." x=\"".$point[0]."\" ";
|
| 32 |
echo "y=\"".$point[1]."\" ";
|
| 33 |
echo "/>";
|
| 34 |
}
|
| 35 |
|
| 36 |
function Init() {
|
| 37 |
$this->Xmin = $_GET['minX'];
|
| 38 |
$this->Xmax = $_GET['maxX'];
|
| 39 |
$this->Ymin = $_GET['minY'];
|
| 40 |
$this->Ymax = $_GET['maxY'];
|
| 41 |
$this->zlevel = $_GET['zoomlevel'];
|
| 42 |
$this->mapaction = $_GET['action'];
|
| 43 |
if ($this->mapaction == 'clicked') {
|
| 44 |
$this->xclicked = $_GET['xclicked'];
|
| 45 |
$this->yclicked = $_GET['yclicked'];
|
| 46 |
$this->idclicked = $_GET['id'];
|
| 47 |
}
|
| 48 |
}
|
| 49 |
|
| 50 |
function AddPoint($x, $y, $id, $info, $icon = "") {
|
| 51 |
$index = count($this->dataarray);
|
| 52 |
$this->dataarray[$index][0] = "point";
|
| 53 |
$this->dataarray[$index][1] = $x;
|
| 54 |
$this->dataarray[$index][2] = $y;
|
| 55 |
$this->dataarray[$index][3] = $id;
|
| 56 |
$this->dataarray[$index][4] = $info;
|
| 57 |
$this->dataarray[$index][5] = $icon;
|
| 58 |
}
|
| 59 |
|
| 60 |
function AddTrace($points, $color = "#ff0000", $weight = 1, $opacity = 0.7) {
|
| 61 |
$index = count($this->dataarray);
|
| 62 |
$this->dataarray[$index][0] = "trace";
|
| 63 |
$this->dataarray[$index][1] = $points;
|
| 64 |
$this->dataarray[$index][2] = $color;
|
| 65 |
$this->dataarray[$index][3] = $weight;
|
| 66 |
$this->dataarray[$index][4] = $opacity;
|
| 67 |
}
|
| 68 |
|
| 69 |
function AddClear() {
|
| 70 |
$index = count($this->dataarray);
|
| 71 |
$this->dataarray[$index][0] = "clear";
|
| 72 |
}
|
| 73 |
|
| 74 |
function AddClearLastTrace() {
|
| 75 |
$index = count($this->dataarray);
|
| 76 |
$this->dataarray[$index][0] = "clearlasttrace";
|
| 77 |
}
|
| 78 |
|
| 79 |
function MoveAndZoom($x, $y, $zl) {
|
| 80 |
$index = count($this->dataarray);
|
| 81 |
$this->dataarray[$index][0] = "move";
|
| 82 |
$this->dataarray[$index][1] = $x;
|
| 83 |
$this->dataarray[$index][2] = $y;
|
| 84 |
$this->dataarray[$index][3] = $zl;
|
| 85 |
}
|
| 86 |
|
| 87 |
function DisplayInfo($id, $info) {
|
| 88 |
$index = count($this->dataarray);
|
| 89 |
$this->dataarray[$index][0] = "info";
|
| 90 |
$this->dataarray[$index][1] = $id;
|
| 91 |
$this->dataarray[$index][2] = $info;
|
| 92 |
}
|
| 93 |
|
| 94 |
function DisplayAlert($alert) {
|
| 95 |
$index = count($this->dataarray);
|
| 96 |
$this->dataarray[$index][0] = "alert";
|
| 97 |
$this->dataarray[$index][1] = $alert;
|
| 98 |
}
|
| 99 |
|
| 100 |
function ShowXMLforAJAX() {
|
| 101 |
header("content-type:text/xml");
|
| 102 |
// echo "<xmldata>\n";
|
| 103 |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xmldata>\n";
|
| 104 |
|
| 105 |
//echo "Count: ".count($this->dataarray);
|
| 106 |
for ($i = 0; $i < count($this->dataarray); $i ++) {
|
| 107 |
|
| 108 |
if ($this->dataarray[$i][0] == "clear") {
|
| 109 |
echo "<data type=\"clear\"></data>";
|
| 110 |
}
|
| 111 |
if ($this->dataarray[$i][0] == "clearlasttrace") {
|
| 112 |
echo "<data type=\"clearlasttrace\"></data>";
|
| 113 |
}
|
| 114 |
if ($this->dataarray[$i][0] == "point") {
|
| 115 |
echo "<data type=\"point\" ";
|
| 116 |
echo "x=\"".$this->dataarray[$i][1]."\" ";
|
| 117 |
echo "y=\"".$this->dataarray[$i][2]."\" ";
|
| 118 |
echo "id=\"".$this->dataarray[$i][3]."\" ";
|
| 119 |
echo "info=\"".htmlentities2unicodeentities($this->dataarray[$i][4])."\" ";
|
| 120 |
echo "icon=\"".$this->dataarray[$i][5]."\" ";
|
| 121 |
echo "></data>\n";
|
| 122 |
}
|
| 123 |
|
| 124 |
if ($this->dataarray[$i][0] == "move") {
|
| 125 |
echo "<data type=\"move\" ";
|
| 126 |
echo "x=\"".$this->dataarray[$i][1]."\" ";
|
| 127 |
echo "y=\"".$this->dataarray[$i][2]."\" ";
|
| 128 |
echo "zl=\"".$this->dataarray[$i][3]."\" ";
|
| 129 |
echo "></data>\n";
|
| 130 |
}
|
| 131 |
if ($this->dataarray[$i][0] == "info") {
|
| 132 |
echo "<data type=\"info\" ";
|
| 133 |
echo "id=\"".$this->dataarray[$i][1]."\" ";
|
| 134 |
echo "text=\"".htmlentities2unicodeentities($this->dataarray[$i][2])."\" ";
|
| 135 |
echo "></data>\n";
|
| 136 |
}
|
| 137 |
if ($this->dataarray[$i][0] == "alert") {
|
| 138 |
echo "<data type=\"alert\" ";
|
| 139 |
echo "alert=\"".htmlentities2unicodeentities($this->dataarray[$i][1])."\" ";
|
| 140 |
echo "></data>\n";
|
| 141 |
}
|
| 142 |
if ($this->dataarray[$i][0] == "trace") {
|
| 143 |
echo "<data type=\"trace\" ";
|
| 144 |
echo "color=\"".$this->dataarray[$i][2]."\" ";
|
| 145 |
echo "weight=\"".$this->dataarray[$i][3]."\" ";
|
| 146 |
echo "opacity=\"".$this->dataarray[$i][4]."\" ";
|
| 147 |
echo ">";
|
| 148 |
for ($j = 0; $j < count($this->dataarray[$i][1]); $j ++) {
|
| 149 |
$this->echoXMLPoint("point", $this->dataarray[$i][1][$j]);
|
| 150 |
}
|
| 151 |
echo "</data>\n";
|
| 152 |
}
|
| 153 |
|
| 154 |
}
|
| 155 |
echo "</xmldata>";
|
| 156 |
}
|
| 157 |
|
| 158 |
}
|