Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.47 KB

geo_json_layer.md

File metadata and controls

52 lines (35 loc) · 1.47 KB

Geo Json Layer

GeoJSON is a common standard for sharing geospatial data on the internet. It is lightweight and easily human-readable, making it ideal for sharing and collaborating.

Build

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

use Ivory\GoogleMap\Layer\GeoJsonLayer;

$geoJsonLayer = new GeoJsonLayer('https://storage.googleapis.com/mapsdevsite/json/google.json');

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

use Ivory\GoogleMap\Layer\GeoJsonLayer;

$geoJsonLayer = new GeoJsonLayer(
    'https://storage.googleapis.com/mapsdevsite/json/google.json',
    ['idPropertyName' => 'id']
);

Configure url

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

$geoJsonLayer->setUrl('https://storage.googleapis.com/mapsdevsite/json/google.json');

Configure options

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

$geoJsonLayer->setOption('idPropertyName', 'id');

Append to a map

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

$map->getLayerManager()->addGeoJsonLayer($geoJsonLayer);