コード例 #1
0
 public function getFeatureCollectionInBounds($latsw, $lngsw, $latne, $lngne, $filters)
 {
     // GeoJSON FeatureCollection
     $collection = new GeoJSON\FeatureCollection();
     //$collection->setBoundingBox(50, 14, 55, 15);
     for ($i = 0; $i < 5; $i++) {
         $point = new GeoJSON\Point();
         $n = mt_rand($latsw, $latne);
         $m = mt_rand($lngsw, $lngne);
         //$m = 50.5;
         //$n = 15.02;
         // firstly set longitude, then latitude...beware!!!
         $point->setCoordinates($m, $n);
         $point->addProperty("id", $i . "moc");
         $point->addProperty("title", $i . "nic moc");
         $point->addProperty("content", "blablabla");
         $point->addProperty("href", "blablabla");
         //$point->addProperty("icon", $this->template->basePath."/images/spinner.gif");
         // add point to FeatureCollection
         $collection->addFeature($point);
     }
     return $collection;
 }
コード例 #2
0
ファイル: test.php プロジェクト: VonShtirlitz/GeoJSON
<?php

require "../vendor/autoload.php";
use GeoJSON\FeatureCollection;
use GeoJSON\Feature;
use GeoJSON\Point;
use GeoJSON\MultiPoint;
?>
<xmp>
<?php 
$collection = new FeatureCollection();
$point = new Point();
$point->setCoordinates(14.5, 50.5);
$point->addProperty("Tetrev hlusec", "Hluchavka");
$multipoint = new MultiPoint();
$multipoint->addCoordinates(14.5, 50.5);
$multipoint->addCoordinates(14.5, 50.5);
$collection->addFeature($point);
$collection->addFeature($multipoint);
echo $collection;