CanvasMap
Getting Started Tutorials 3D Reference

Changing Settings

Setting Settings

CanvasMap uses a uniform and very flexible system for setting settings in layers and other items. The setings are defined for each class in the reference documentation. You can set settings individually or as a group of settings. For layers, you can set settings based on an attribute column or for each individual feature. The first example map of Africa shows each of these methods.

The code below shows the general format for setting an individual setting:

TheObject.SetSetting("Group","Setting",Value); 

A specific example for a layer would be:

TheLayer.SetSetting("MouseOverStyle","fillStyle","rgb(0,0,0)"); 

Setting Settings from Attributes

You can also set properties to have values pulled from an attribute table for layers. This allows you to customize the properties for each feature in a layer. In the function below, we'd use the appropriate setting value to the name of the column in the attribute table that contains the value for the settings for each feature. The values in the table can be blank to indicate you want to use the default setting value.

TheLayer.SetSettingAttribute("Group","Setting","ColumnHeader");

One of the most common times you'll use SetSettingAttribute() is to set the attribute that contains HTML that will appear in the information popup balloons when the user clicks on a feature. The code below will have this information come from the "InfoHTML" attribute in a layer.

TheLayer.SetSettingAttribute("Layer","InfoText","InfoHTML");

Setting Settings for Individual Features

You can also set properties for individual features within your files. This allows us a great deal of flexibility in colorizing our maps, among other uses. The "SetFeatureSetting()" function will set a setting for an individual feature using an index to that feature from 0 being the first feature in the layer.

TheLayer.SetFeatureSettingGroup(Group,FeatureIndex,OneFeaturesSettingGroup);
TheLayer.SetFeatureSetting(Group,Key,FeatureIndex,Value);

Below is an example of setting unique groups for each feature and the US Census example uses this approach to uniquely colorize a data set of counties based on their population.

for (var i=0;i<TheDataset.GetNumAttributeRows();i++)
{
	var FeatureStyle={
		fillStyle:FeatureColors[i],
		strokeStyle:"rgba(220,220,200,0.8)"
	};
	Layer_Counties.SetFeatureSettingGroup("Style",i,FeatureStyle);
};