Using Generic JavaScript View to create a google maps choropleth map with custom boundaries

I’ve been trying to adapt the Choropleth world map to show a custom set of boundaries (loaded from a GeoJSON) for a current project I’m working on.

I’ve been following Rarylson’s work on github and managed to create the map I wanted using HTML - the code and screenshot of the map can be viewed here.

I’ve been attempting to recreate this map in the Generic JavaScript View node by loading the script from Rarylson with jQuery in conjunction with loading the Google Maps scripts (with API key) but am struggling to get anything to show up. The Knime tutorial on Choropleth maps mentioned that jQuery isn’t always suitable for loading multiple scripts - especially with dependencies, could this be a cause of issues?

Additionally - if there is a way of embedding my functional HTML code into a Knime node that could be the easiest method.

Many thanks for any support!


Hi there,
cool stuff you are planning here.

Just today we released two new verified components by @ahmadvarasteh adopting the GeoChart library. You can currently find the components and examples through KNIME Verified Components | KNIME

We update this page so we are going to also post the component links here below:

  1. Choropleth Map – KNIME Hub

  2. Dot Map – KNIME Hub

In both cases examples are available if you scroll down in the KNIME Hub component page.

The new components lets you change the map region (not just displaying the entire world map like the former one we released and you found). You can also change the boundaries and show provinces borders.

Unfortunately neither component offers the option to load custom boundaries. I totally understand your use case. Data is available online in GeoJSON format with boundaries (small custom regions usually) and that could be the only way if what you want to display is super custom and not available as a GeoChart setting.

I would try the following:

  • Check whether GeoChart already offers those boundaries using the setting “resolution” either as “provinces” or “metro” and changing “region” on the world area you use case needs to cover. You can check on your own here or take a look at this screenshot from the same page.

  • If it is covered by “provinces” then no need for coding: simply adopt the new components and adjust the component settings to what you need. (look at @ahmadvarasteh’s examples to see how to do that)

  • If you require “metros” then you need to drag and drop one of the component, unlink and then edit the JavaScript node inside. There is a flow variable that dynamically change the js setting “resolution”. You could manually change it to “metros” and that should do it +/- a bit of workflow hacking and the proper data input.

  • If neither “provinces” or “metros” cover your boundary use case, then yeah we need to link into how to import this GitHub library you found next to GeoChart by Google. Let me know and I will give you a few examples after syncing with our devs.

Regarding writing in HTML on which to apply JavaScript: we are aware that unfortunately the generic js node does not offer a place to write your HTML next to the CSS and JavaScript you provide there. There is another node for writing HTML ( that would be Text Output Widget node) but your js code from the generic js node cannot be applied on the html generated by another node. Therefore, until we fix this, you need to write more js code that generates the HTML before applying any further js code. I personally use d3 for this.


Hi, thanks for the comprehensive reply!

So the boundaries I’m using are for specific healthcare regions in the UK so definitely need to load in a custom GeoJSON - seeing an example would be amazing.

Thanks for the help!


All right, I checked with our devs and I found out that:
To use that GitHub approach you need an API from Google GeoCharts.
Our components do not and that’s already a big difference.

Either way you have two methods to import both js libraries in the Generic JS View node:

  1. Using “require.config”
	paths: {
		// delete this comment once you have put in your maps key
		"google": "$Put_in_Key_without_the_dollar_signs$",
       	"GeoJson": "",
require(["google", "GeoJson"], function() {
	// geochart now available under geochart_geojson
  1. Using jQuery getScript()
function googleLoaded() {
		.done(function(script, textStatus) {
				.done(function( script, textStatus ) {
// Load Google JavaScript API via jQuery getScript()
	.done(function( script, textStatus ) {
		google.charts.load("current", {packages: ['corechart', 'geochart']});
	.fail(function( jqxhr, settings, exception ) {
		// Inform user about failure
		alert("Loading Google API failed.");

In both cases there is $Put_in_Key_without_the_dollar_signs$ to be replaced with your Google GeoChart API key.

In the second case you also need to check the box in the top of the Generic JS View dialogue as shown below in the screenshot:

Regarding the HTML are you able to write some js code to build it?

Either way if you get stuck send your workflow in here with attached data.
To learn how to store data (the geojson and the table) inside the workflow data area see this example:



This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.