Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 1.55 KB

kml_layer.md

File metadata and controls

60 lines (40 loc) · 1.55 KB

KML Layer

The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. For more information, read the official documentation.

Build

First of all, if you want to render a kml layer, you will need to build one. So let's go:

use Ivory\GoogleMap\Layer\KmlLayer;

$kmlLayer = new KmlLayer('http://www.domain.com/kml_layer.kml');

The kml layer constructor requires an url as first argument. It also accepts additional parameters such as options (default empty):

use Ivory\GoogleMap\Layer\KmlLayer;

$kmlLayer = new KmlLayer(
    'http://www.domain.com/kml_layer.kml',
    ['suppressInfoWindows' => true]
);

Configure variable

A variable is automatically generated when creating a kml layer but if you want to update it, you can use:

$kmlLayer->setVariable('kml_layer');

Configure url

If you want to update the kml layer url, you can use:

$kmlLayer->setUrl('http://www.domain.com/kml_layer.kml');

Configure options

The kml layer options allows you to configure additional kml layer aspects. See the list of available options in the official documentation. Then, to configure them, you can use:

$kmlLayer->setOption('suppressInfoWindows', true);

Append to a map

After building your kml layer, you need to add it to a map with:

$map->getLayerManager()->addKmlLayer($kmlLayer);