[opengeodb] Neuentwicklung einer Geo-class in PHP
prog wut
progwut at googlemail.com
Mit Aug 20 19:40:09 CEST 2008
Wie versprochen hier mal ein kleines Beispiel:
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Klasse einbinden
require_once 'TMyMap.php';
// Karte laden
$obj = new TMyMap('deutschland.gif');
// Range setzen
$range = array();
$range['x']['min'] = 5.5201;
$range['x']['max'] = 15.0237;
$range['y']['min'] = 47.1615;
$range['y']['max'] = 55.0333;
$obj->setRange($range);
// Eine location einzeichen an der Position lon, lat.
// Zusätzlich eingezeichneten Punkt über eine Imagemap verfügbar machen
// Farbe des eingezeichneten Punktes ist col
$geo = array('lon'=>50.59,
'lat'=>11.2,
'write' => TMyMap::WRITE_AREASHAPE+
TMyMap::WRITE_POINT+
TMyMap::WRITE_DIV,
'color' => array('r' => 1, 'g' => 255, 'b' =>255),
'areashape' => array('href'=>'http://www.google.de',
'title'=>'google!', 'alt'=>'google')
);
$obj->writeGeoObj($geo);
// Radien um die Location malen mit 20 und 40px Abstand
// Farbe der Radien bei color
$ra= array('radius' =>
array('size' => 20,
'color' => array('r'=>255, 'g'=>0, 'b'=>0)
),
array('size' => 40,
'color' => array('r' => 0, 'g'=>255, 'b'=>0))
);
$obj->writeRadius($geo,$ra);
// Bild auf Dateisystem schreiben, überschreiben wenn bereits existiert.
$obj->saveImage("deutschland_ready.gif",true);
?>
<html>
<head>
<title>dyn Map</title>
<style>
.map_div
{
border:1px solid red;
position:absolute;
width:200px;
height:100px;
}
</style>
</head>
<body>
<!-- BEGINN AUSGABE DER KARTE -->
<img src="deutschland_ready.gif" align="left" usemap="#Landkarte"
border="0" />
<?php
// Punkt vorhanden der ueber eine DIV positioniert wird
if($obj->getGeoObjTypes(TMyMap::WRITE_DIV))
{
?>
<?php
foreach($obj->getGeoObjAry(TMyMap::WRITE_DIV) as $geo)
{
?>
<div id="<?php echo md5($geo['lon'].$geo['lat']); ?>"
class="map_div" style="top:<?php echo $geo['div']['pos']['x'];
?>px;left:<?php echo $geo['div']['pos']['x']; ?>px;">
<?php echo $geo['y']."/".$geo['lat']; ?>
</div>
<?php
}
?>
<?php
}
?>
<?php
// Ist ein Punkt vorhanden für welchen eine Imagemap gezeichnet werden
soll
if($obj->getGeoObjTypes(TMyMap::WRITE_AREASHAPE))
{
?>
<map name="Landkarte">
<?php
foreach($obj->getGeoObjAry(TMyMap::WRITE_AREASHAPE) as $geo)
{
?>
<area shape="circle" coords="<?php echo
$geo['x'].",".$geo['y'].",".$geo['width']; ?>"
href="<?php echo $geo['areashape']['href']; ?>" alt="<?php
echo $geo['areashape']['alt']; ?>" title="<?php echo
$geo['areashape']['title']; ?>">
<?
}
?>
</map>
<?php
}
?>
<!-- ENDE AUSGABE DER KARTE -->
</body></html>
-------------- nächster Teil --------------
Ein Dateianhang mit HTML-Daten wurde abgetrennt...
URL: http://lists.phpbar.de/pipermail/opengeodb/attachments/20080820/6dd5d156/attachment-0001.htm