The fx-editor
The Power of NPGeoMap

Home navigation:   NPGeoMap Properties Dialog >

The fx-editor
The Power of NPGeoMap

Zum deutschen Handbuch wechseln NPGeoMap

Version 2.50.84, 07.12.2017

Clicking the  fx  symbols/buttons* in the properties opens the internal Sense expression editor in the "Edit Expression" window - in this manual called the fx‑editor.
Custom editable expressions make nearly all features in NPGeoMap extremely dynamic and connect them to the entire data model, by using Sense fields, formulas and variables as well as building interactive Input Boxes, Buttons or Sliders.
The fx‑editor lets you program and develop directly in your application.

Interactive connection to your Sense data,
by using Sense fields, formulas and variables.

click to expand

click to expand

At the end of the fx‑editor dialogs or nearby the features there is always a short description for every setting of the default expression (except for the Expert Settings, due to a character limitation of Sense).
The expressions again are configured in two different notations - JSON and the NPGeoMap #Hashtag Notation.
Basically all fx‑editor dialogs are predefined and you just have to change the specific settings. The following is supportive for professional configurations.

*(Except the Expert Settings - it's the only dialog without description due tu a limitation of characters from Sense.)

See detailed information in the following topics:

1.Updates und Compatibility

2.Notations

oJSON

9some more details about JSON

oNPGeoMap #Hashtag Notation

3.NPGeoMap #Hashtag Variables

4.Remarks

5.HTML - see the basics

6.Set Colors

7.Working with Formulas

8.Tips and Hints

 

1. Updates und Compatibility

By installing an updated version of NPGeoMap, no fx‑editor dialog content of existing objects will be changed. But possibly new features or other improvements work right away. A now added object contains all new contents.

Existing objects stay as they are, but can use all new features.

 
Use new features in existing objects by copy and paste whole dialogs or just the updated parts of a fx‑editor from a new added NPGeoMap object.

 

2. Notations

The dialogs in the fx‑editors are either configured in JSON or the NPGeoMap #Hashtag Notation:

oJSON

oNPGeoMap #Hashtag Notation

Both of them are easy to read and simple structured.
Benefit of the NPGeoMap #Hashtag Notation is beeing very slim and fast, when JSON can handle more complex structures best.
The content of PopUps and MouseOvers (Tooltips) can even be edited with HTML.

Almost every setting can be configured by using Sense fields, formulas or variables.

All available features are listed in the fx‑editor dialogs. They all have default settings* - therefore deleting content doesn't change how the program works. It's just a way to customize your object in the most flexible way.
Even more it's a performance tip to cut out (or remark) all features and settings you don't need.

*Note that sometimes the predefined default settings in the fx‑editors are not the fallback settings (the ones which are used, when the feature is deleted or configured incorrectly) in the program.

 

See which notation is used in a fx‑editor:

JSON notation

every dialog begins with a part enclosed from star characters ***

NPGeoMap #Hashtag notation

every setting begins with one or two hash marks ##

click to expand

click to expand

click to expand

click to expand

List of all editor dialogs and their notation:

dialogs with
JSON Notation

dialogs with
NPGeoMap #Hashtag Notation

 

2.a) JSON

JSON (say 010_JSON) stands for JavaScript Object Notation and is a simple format for data exchange. It's independent from any programing language. Therefore it's the best way to communicate between Sense and NPGeoMap.

click to expand

click to expand

Rules of Notation:

Basic rule: the relevant JSON text parts are enclosed from single quotes 'json block'.

To integrate Sense fields, formulas or variables, the JSON block has to be interrupted - again with single quotes (because JSON text blocks always have to be enclosed by single quotes) - and the several parts have to be connected with an ampersand & :

' json block ' &  Sense formula  & ' json block ' &  Sense field  & ' json block '

The Sense parts themselves don't need quotes.
Within the JSON text blocks complex nesting is possible on a simple principle - after each open curly bracket { another one can be set before they are closed again } .

Line breaks and spaces don't have to be strictly considered in JSON.

Further Rules:

kind of text

rules and definition

{

objekt1,

objekt2

}

Objects are always enclosed by curly brackets {object} , several objects are separated by comma , . Attention: after the last object must NOT be a comma.
Following this style, nesting can be configured with "sub-objects".

Symbolic Example:

{objekt1
     {subobjekt1,subobjekt2},

objekt2
     {subobjekt3,subobjekt4}}

Practical Example:

{"Data":
     {"LoadData": 1,
      "loaddatamessage": "Hello"},

"Design":
     {"theme": "grey",

      "selectedpolygoncolor": "lightgrey"}}

"key": value

All settings consist of a key and a value. The key has to be enclosed by double quotes "key" (values are explained in the second part of this table). Within an object every key has to be individual.

Symbolic Example:

{ "key1": value1 ,

 "key2": value2  }

Practical Example:

{ "LoadData": 1 ,

 "loaddatamessage": "Hello" }

[

array1,

array2

]

A list, called array, is always enclosed by square brackets [array] , several arrays are separated by comma , . Attention: after the last array must NOT be a comma.
Arrays can be a nesting too - they may contain values, objects or further arrays.

Symbolic Example
one object containing two arrays of values:

{

 [value1, value2, value3],

 [valueA, valueB, valueC]

}

Practical Example
of the quick zoom menu (array of several objects):

click to expand

click to expand

the values

A value can be one of the four following defined ones or another object itself (nesting).

true

or

false

The words true and false are in this case so called boolean values. Therefore they don't have to be enclosed by double quotes like other text. They can always be replaced by 1 (true) or 0 (false) in NPGeoMap.
True means yes or active, false means no or disabled.

Symbolic Example:

{"key1": true,

"key2": false}

Practical Example:

{"wrapDateLine": true,
"showScaleLine": false}

0-9

digits

Numbers as well don't have to be enclosed by double quotes. Number values may only contain digits from 0 to 9, a decimal separator and possibly a negative sign. They must NOT contain any additions or extensions like sec or ft.
As decimal separator a point like 1.5 has to be used.
NPGeoMap only operates with a point as decimal separator.

Note that coordinates don't apply as numbers, but as text!

Symbolic Example:

{"key1": 0 ,

"key2": 2.5 }

Practical Example:

{"simplifytype": 0,

"labelfontsize": 12.5}

"text/string"

All other concatenations of characters and marks are text - so called string - and have to be enclosed by double quotes.

Note that coordinates as well apply as text, not as number!

Labels, PopUps and MouseOvers (Tooltips) always expect text values - if you want to use formulas here, the result has to be enclosed by double quotes as well.

Symbolic Example:

{"key1": "color name",

"key2": "coordinates"}

Practical Example:

{"bordercolor": "blue",

"coordinates": "48.208102, 16.369760"}

Sense
fields, formulas or variables

To integrate Sense fields, formulas or variables, the JSON block has to be interrupted with single quotes (because JSON text blocks always have to be enclosed by single quotes) and the several parts have to be connected with an ampersand & . The Sense parts themselves don't need quotes.

' json block ' &  Sense formula  & ' json block '

Attention: When Sense calculates something, it depends on the Sense script (country-specific) which decimal separators are returned with the numbers (can be commas or spaces...). NPGeoMap only operates with a point as decimal separator.

Beware of the expected result of formulas - if they return a string or an empty value, the block has to be concatenated with enclosing double quotes. In this case the quotes are part of the JSON text block, not of the Sense block:

{"key1": " '& Sense formula &' "}

Labels, PopUps and MouseOvers (Tooltips) always expect text values - if you want to use formulas here, the result has to be enclosed by double quotes as well.

See more tips and hints when using formulas further below.

Symbolic Example:

{"key1": '& Sense variable &',

"key2": '& Sense formula &'}

Practical Example:

{"zoomBuffer": '& vZoomBuffer &',

"popup": "'& Count(ID) &'"}

Some more details about JSON:

If you use HTML within a JSON string (like for a Simple Marker PopUp), beware of special characters.
Especially quotes have to be "escaped" by setting a backslash before them: \"

000_warning Important: To use local saved images, this Sense image path has to be set in the HTML tag (this applies for all dialogs):

 ../Extensions/NPGeoMapSense_v2.50/images/[...]

Again, in JSON the quotes have to be considered - with escaped quotes, the HTML image tag looks like that:

<img src=\"../Extensions/NPGeoMapSense_v2.50/images/flag.png\">

 

More about JSON at json.org or wikipedia.org/JSON.

 

2.b) NPGeoMap #Hashtag Notation

This notation was developed specially for NPGeoMap and it's main advantage is to be very slim and simple - that makes it fast and turns out a very good performance.

Unlike JSON not the whole text block, but each setting itself has to be enclosed by single quotes 'setting' .
As well they are all connected by ampersand & :

JSON Notation

' json block ' &  Sense formula  & ' json block '

NPGeoMap #Hashtag Notation

Symbolic Example:

'setting' & any value & 'setting' & any value

Practical Example:

'#Type=' &  2  & '#Color=' & 'orange'

Therefore there's no need to separate the several settings by comma.
If the value is enclosed by single quotes as well or not, depends on the kind of value - see table below.

The settings always begin with a hash mark # and end with a equal sign = .

'#setting='

A simple nesting is possible too in this notation, by using two hash marks ## for the second level at the beginning of a setting and end them with a colon : .

'#level1='
    &'##level2:'

This notation makes it easy to remark parts by setting two slashes // . (See details further below at Remarks.)

The rules and definitions for values in this notation are similar to the ones for JSON:

value

definition

0-9

digits

Numbers as well don't have to be enclosed by double quotes. Number values may only contain digits from 0 to 9, a decimal separator and possibly a negative sign. They must NOT contain any additions or extensions like sec or ft.
As decimal separator a point like 1.5 has to be used.
NPGeoMap only operates with a point as decimal separator.

Note that coordinates don't apply as numbers, but as text!

Symbolic Example:

'#setting=' & 0

&'#setting=' & 2.5

Practical Example:

'#Type=' & 3

&'#Size=' & 12.5

'text/string'

All other concatenations of characters and marks are text - so called string - and have to be enclosed by single quotes.

Note that coordinates as well apply as text, not as number!

Labels, PopUps and MouseOvers (Tooltips) always expect text values - if you want to use formulas here, the result (not the formula itself - see example in next entry "Sense") has to be enclosed by single quotes.

Symbolic Example:

'#setting=' & 'color'

&'#setting=' & 'coordinates'

Practical Example:

'#Color=' & 'blue'

&'#MarkerImageURL=' & 'image.png'

Sense
fields, formulas or variables

Integrating Sense fields, formulas or variables is very easy in this notation - they don't need quotes. The parts just have to be connected by ampersand, but this is usually predefined in every fx‑editor.

'#setting=' &  Sense formula  & '#setting='

Attention: When Sense calculates something, it depends on the Sense script (country-specific) which decimal separators are returned with the numbers (can be commas or spaces...). NPGeoMap only operates with a point as decimal separator.

Labels, PopUps and MouseOvers (Tooltips) always expect text values - if you want to use formulas here, the result has to be enclosed by single quotes as well.

See more tips and hints when using formulas further below.

Symbolic Example:

'#setting=' & Sense variable

&'#setting=' & Sense formula

Practical Example:

'#Popup=' & vPopup

&'#MouseOver=' & Count(ID)

3. NPGeoMap #Hashtag Variables

These special variables are simple auxiliary tools, available in these three JSON using fx‑editors:

Simple Marker

Simple Maps

Radial Spheres

The description within the fx‑editor dialogs (at the end of each fx‑editor) and the respective entry in this Manual list up exactly, which variables are available for which feature.

Basic structure of the NPGeoMap #Hashtag Variables:
  [#variable]

These variables return values, which Sense cannot determine, because only NPGeoMap is able to interpret the variables and read their results out.

Like strings/text the variables have to be enclosed by double quotes. You can use them as building blocks directly in a text.

Example Simple Marker (combined with HTML):

"mouseover": "[#Name]<br>lives in [#ID]",

Example Radial Spheres:

"popup": "circumradius branch: [#SphereRadius][#UnitsFactor]",

 

4. Remarks

Remarking parts of a code or the content of a fx‑editor means to exclude this part from calculating/interpreting. This may concern notes, description parts or parts, that are not needed at the moment.

In NPGeoMap #Hashtag notation single rows can be remarked by beginning them with two slash marks // ,
or whole text parts can be remarked by enclosing them with /* at the beginning and */ at the end of it.

Remarking parts in a fx‑editor in NPGeoMap #Hashtag notation which aren't used or needed, increases the performance a lot.

In JSON the remarks can only be inserted in the "interrupted parts" (see description JSON above) by using /* at the beginning and */ at the end of it:

' json block ' /*  remarked text  */ & ' json block '

 

A lot of remarked text contains important hints, useful templates, captions and descriptions - pay attention to them, they will help you!

 
At the beginning of most fx‑editor you can find some tips and hints concerning the following content, as well as templates to set several features.
After the predefined settings, every fx‑editor contains short descriptions of all features for a quick and easy help.
Sometimes short hints are directly nearby several features.

 

5. HTML - see the Basics

Some settings can be configured with HTML, like PopUps and MouseOvers (Tooltips).
Integrate HTML tags always directly in the text - NPGeoMap will interpret it. Therefore HTML has to be enclosed by quotes as well.

See here some basic tags:

HTML tag

short description

<h1>text</h1>
<h2>text</h2>
...

"heading" 1 to 6
displays headings from very big (1) to very small (6)

<b>text</b>

"bold" - bold text

<i>text</i>

"italic" - italic text

<u>text</u>

"underline" - underlined text

<br>

"line break"
(tag don't has to be closed)

<hr>

"horizontal line"
(tag don't has to be closed)

<a href="url"> link text </a>

basic link
instead of url fill in a web link, the link text will be displayed

000_warning Important: To use local saved images, this Sense image path has to be set in the HTML tag (this applies for all dialogs):

 ../Extensions/NPGeoMapSense_v2.50/images/[...]

More details about HTML for example at www.w3schools.com.
 

6. Set Colors

In NPGeoMap there are many opportunities to set colors. There are several possibilities to do so like using Hex Codes, HTML color names or the Sense RGB formula.

This is an example for the color RED:

method

JSON notation

NPGeoMap #Hashtag notation

Hex Code

"#FF0000"

'#FF0000'

HTML color name

"red"

'red'

RGB Sense formula

'& RGB(255, 0, 0) &'

RGB(255, 0, 0)

 
For the background color of the Legend even a RGBA value may be set (A stands for the transparancy) - it then overwrites the opacity setting there.

To discover nice colors, combinations and gradients try one of these:

 
 

7. Working with Formulas

Here are some useful tips and hints, when using formulas in the fx‑editors:

oDirectly in Sense formulas a point has to be used as a decimal separator - commas separate the individual parts of the formula. This is valid regardless of other settings to decimal separators.

oWhen Sense calculates numbers, it depends on the Sense script (country-specific) which decimal separators are returned with the numbers (can be commas or spaces...). NPGeoMap only operates with a point as decimal separator.

oBeware of the expected result of formulas in JSON - if they return a string (text) or an empty value, the block has to be concatenated with enclosing double quotes.

 

8. Tips and Hints

010_formel_editor_2

In fx‑editor dialogs it's very important carefully add or change every character - a missing comma or a wrong bracket can cause, that the whole dialog can't be interpreted right. Two things will help you with checking your configuration:

oFirst, in the upper left corner of the window, a short hint is displayed, which in best case says "Expression OK".

oFurther NPGeoMap provides a lot of detailed error messages in the object, that will help you solving the issue.

Due to a browser timeout, keeping a fx‑editor window open for a certain time may cause a message when closing the window (see screenshot on the right). It will ask you to "Stop running this script?".
If you click on  Yes , all your changes made in the fx‑editor will be lost! Therefore you can always click on  No  - nothing bad will happen.

click to expand

click to expand