dev-master
9999999-dev https://github.com/perspectivain/yii2-geoAn interface to generate geographic annotations in different formats
MIT
The Requires
by Juliano Baggio di Sopra
yii2 geojson kml
An interface to generate geographic annotations in different formats
An interface to generate geographic annotations in different formats., (*1)
Currently supports KML and geoJSON formats and MultiPolygon, Point and Polygon types., (*2)
More about geoJSON: http://geojson.org/geojson-spec.html More about KML: https://developers.google.com/kml/documentation/
Create and action to response in geo format, (*3)
use perspectivain\geo\kml\Kml; use perspectivain\geo\kml\models\Polygon; use perspectivain\geo\kml\models\Point; public function actionCityDistricts() { $document = new Kml; //change to "new Geojson" to generate this file $document->id = 'district'; $districts = District::find()->all(); foreach($districts as $district) { $polygon = new Polygon; foreach($district->coordinates as $coordinate) { $point = new Point; $point->value = $coordinate; $polygon->value[] = $point; unset($point); } $document->add($polygon); unset($polygon); } return $document->output(); }
And the return is an valid KML file, (*4)
To pass properties to object, do this:, (*5)
$polygon = new Polygon; $polygon->extendedData = [ 'property' => 1, ];
The preferred way to install this extension is through composer., (*6)
``` { "require": { "perspectivain/yii2-geo": "*" } }, (*7)
An interface to generate geographic annotations in different formats
MIT
yii2 geojson kml