GC2 JavaScript

JavaScript API

The GC2 JavaScript API is a thin wrapper around Leaflet. It makes it easy to initiate a Leaflet map with tile and vector overlays from a GC2 server. Also it defines commonly used base layers from providers like OSM, Google, Bing, HERE, Yandex and Stamen.

JavaScript Widget

The GC2 JavaScript Widget is a ready-for-use embeddable widget for web-pages. It adds legend and click-info to the map and have i18n support. It loads the layer meta data from the GC2 server and uses the titles, click-info setups etc. The widget can be extended through the GC2 JavaScript API.

JavaScript API

Basic tile map

Basic example. Map with a base layer and a tile overlay. An tile overlay can be refereed to as [schema].[table]

Show me Source

Map with multiple base layers and tile overlays

Map with multiple base layers and tile overlays with custom titles. The API defines several base layers. If Google Maps are used, the API will asynchronously load the Google Maps API.

Show me Source

Basic vector map

Map with vector overlay from a SQL store. The store loads data as GeoJSON defined by a SELECT query.

Show me Source

Map with custom Awesome Markers and pop-up

Use Awesome Markers instead of the Leaflet default markers. Also bind pop-ups to the markers and cache the query on the server

Show me Source

Map with styled overlay

Load polygon vectors from a SQL store and add custom classified style map.

Show me Source

Map with async loading

The GC2 API, Leaflet and all other scripts and stylesheets can be loaded asynchronously.

Show me Source

Map with cluster plug-in

Use of the Leaflet markercluster plug-in.

Show me Source

Map with heatmap plug-in

Use of the Leaflet heatmap plug-in.

Show me Source

OpenLayers map

OpenLayers can be used instead of Leaflet. Just specify it in the URL to the API.

Show me Source

JavaScript Widget

Basic widget

Basic example. With one tile layer and default base layers of the GC2 server

Show me Source

Widget with a custom base layer set

Widget with multiple tile layers and custom set of base layers.

Show me Source

Widget with a vector overlay

Access the geocloud and native Leaflet object using the callback function.

Show me Source

Widget with asynchronously loaded layers

Adding of tile layers after the widget is ready.

Show me Source

Multiple Widgets on same web page

Each widget is encapsulated, so its safe to have more that one on each page.

Show me Source

Widget with forced locale

By default the locale is detected from the HTTP request header. But its possible to force a locale.

Show me Source