Client library for interacting with embedded map
Switch branches/tags
Clone or download
Latest commit b58cce9 Jan 24, 2018

RPC-client for

Client library for interacting with embedded maps


1) Publish a map from an Oskari instance

Publishing a map will give you a html-fragment like this:

	<iframe src=""></iframe>

2) Add an id to the iframe-element and add it to your page with a script to load the rpc-client.js and to initialize the connection:

	<iframe id="map" src=""></iframe>
	<script src="dist/rpc-client.min.js"></script>
		// init connection
		var IFRAME_DOMAIN = "";
		var channel = OskariRPC.connect(document.getElementById('map'), IFRAME_DOMAIN);
  • rpc-client.min.js can be found in the dist-folder in this repository
  • Notice that the value of IFRAME_DOMAIN must match the domain of the Oskari instance hosting the map.

3) onReady-function is called when the connection to the map has been established successfully.

You can get additional information and check that the client version you are using is supported by the running Oskari-instance when connected:

	channel.onReady(function() {
	    //channel is now ready and listening.
	    channel.log('Map is now listening');
	    var expectedOskariVersion = '1.35.0';
	    channel.isSupported(expectedOskariVersion, function(blnSupported) {
	        if(blnSupported) {
	            channel.log('Client is supported and Oskari version is ' + expectedOskariVersion);
	        } else {
	            channel.log('Oskari-instance is not the one we expect (' + expectedOskariVersion + ') or client not supported');
	            // getInfo can be used to get the current Oskari version
	            channel.getInfo(function(oskariInfo) {
	                channel.log('Current Oskari-instance reports version as: ', oskariInfo);
	    channel.isSupported(function(blnSupported) {
	        if(!blnSupported) {
	            channel.log('Oskari reported client version (' + OskariRPC.VERSION + ') is not supported.' +
	            'The client might work, but some features are not compatible.');
	        } else {
	            channel.log('Client is supported by Oskari.');

4) After this you can start using the API.

You can check supported features in the Oskari-instance you are using:

	channel.getSupportedEvents(function(supported) {
		channel.log('Supported events', supported);

	channel.getSupportedRequests(function(supported) {
		channel.log('Supported requests', supported);

	channel.getSupportedFunctions(function(supported) {
		channel.log('Supported functions', supported);

	// supported functions can also be detected by
	if (typeof channel.getAllLayers === 'function') {
		channel.getAllLayers(function(layers) {
			channel.log('Available layers', layers);
  • Events are used as notification of something that happened on the map like the user clicked the map, the map moved etc.
  • Requests are used to command the map like move the viewport of the map to show certain location.
  • Functions can be used to get information about the map like current bounding box or zoom level.

You can find the API documentation including an API changelog in Also more information can be found in and

npm install

npm install oskari-rpc

Development tools

Building the dist packages

  1. Run npm install to install the dependencies/build tools

  2. Run npm run build to run the Gulp-build

  3. Find the updated rpc-client.js and rpc-client.min.js in dist-folder.

Running JSHint

Run npm run lint to detect errors.

Running JSCS

Run npm run format to check codestyle and fix it.