Mapcode PHP version ' . mapcode_phpversion . ' example';
$input = trim($_REQUEST["s"]);
if ($input != NULL) {
//$input = utf8_decode(mb_convert_encoding($input,"utf-8" ));
if (strpos($input, ',') !== false) // conrtains a comma, so assume coordinates
{
$p = strpos($input, ',');
$lat = substr($input, 0, $p);
$lon = substr($input, $p + 1);
$precision = 0;
$r = encodeShortestWithPrecision($lat, $lon, $precision);
$n = count($r);
echo 'Coordinate ' . $lat . ' , ' . $lon . ' has mapcodes in ' . $n . ' territories:
';
for ($i = 0; $i < $n; $i++) {
$p = strpos($r[$i], ' ');
$territory = ($p === false ? "AAA" : substr($r[$i], 0, $p));
echo ' ' . $r[$i] . ' (' . getTerritoryFullname($territory) . ')
';
}
echo '
';
} else // assume mapcode
{
$asc = convertToAlphabet($input, 0);
echo 'Input
"' . $input . '"';
if ($asc != $input) {
echo ' (romanized as ' . $asc . ')';
}
$d = decode($input);
if ($d == 0) {
echo '
is not a valid mapcode
';
if (strpos($input, ' ') === false) {
echo '(did you include the territory?)
';
}
} else {
echo '
decodes to coordinate
' . number_format($d->lat, 9) . ',' . number_format($d->lon, 8) . '
';
}
echo '
';
}
}
// ----------------------- end of PHP ---------------------
?>
Enter a mapcode
(e.g. NLD 49.4V
or MOW ПЖ.УБ
or MH
५ग.सडज)
or a coordinate
(e.g. 52.3765, 4.908)
and press OK