Overview of functions by geocubes Javascript API
Constructor:
function gcGrid (GMap2 MapObj, string geocubes_key)
|
Description:
This is the central class of the geocubes API. It contains all functionality to control the clusters and points on your map. You need to call the constructor to use the functions of the API. Please do not forget to call the function enableRenderGrid after you set all options to geocubes. This enables the rendering of the clusters and points to your map.
|
Example:
/*
...code...
var map = new GMap2(document.getElementById("map"));
...code...
*/
// create geocubes object
var gcGridObj = new gcGrid(map, "GEOCUBES_API_KEY");
|
|
|
Function:
function setRendering (var type)
|
Description:
geocubes supports two clustering algorithms. You can switch between point clouds and cubes. You have also the possibility to change it at runtime. The default clusering algorithm is always cubes. Please note: geocubes have different callback names for clouds and cubes, e.g. GC_CB_ONCREATECLOUD and GC_CB_ONCREATECLUSTER
|
Constants:
var GC_RND_CUBES; // clustering with cubes
var GC_RND_CLOUDS; // point cloud clustering
|
Example:
// sets the clustering to "clouds"
gcGridObj.setRendering(GC_RND_CLOUDS);
|
Notes:
Default clustering is GC_RND_CUBES.
|
|
|
Function:
function setIcon (var type, GIcon icon)
|
Description:
If you want to change the design of your icons for points and clusters you have to use this function. There are different constants for the several icon types.
|
Constants:
var GC_IC_POINT; // Icon for single Points
var GC_IC_POINTMOUSEOVER; // Icon for mouseover effect on points
var GC_IC_CLUSTER; // Icon for clusters
var GC_IC_CLUSTERMOUSEOVER; // Icon for mouseover effect on clusters
|
Example:
// create google maps icon
var MyIcon = new GIcon();
MyIcon.image = "http://url.example.com/images/icon.png";
// sets the icon for single points to "MyIcon"
gcGridObj.setIcon(GC_IC_POINT, MyIcon);
|
Notes:
If you don't change icons geocubes will show a default icon for points and clusters. If you add an icon for mouseover effects the API will change the icon back to your normal icon on mouseout event automatically.
|
|
|
Function:
function setOption (var type, int on_off)
|
Description:
This function changes options of geocubes. The parameter "on_off" can be 0 for deactivate or 1 for activate.
|
Constants:
var GC_OP_CLUSTERCOUNT; // show up the counters over the clusters that indicates
// the number of geo points contained in the cluster
|
Example:
// activate the option to show up the counters over the clusters
gcGridObj.setOption(GC_OP_CLUSTERCOUNT, 1);
|
|
|
Function:
function setVar (var type, mixed value)
|
Description:
This function is used to set several variables. You can find the different variable types under constants below.
|
Constants:
var GC_VR_COUNTDESCR; // adds a text behind the counters of the clusters
|
Example:
gcGridObj.setVar(GC_VR_COUNTDESCR, " points"); // this will show "954 points" on the cluster
|
|
|
Function:
function setCallback (var type, function cb_func)
|
Description:
For several events in your map you can define own functions that will be called by the API. You can set them by using setCallback. The first parameter is the constant for an event type and the second is your custom function. You will find the event types that are supported by the API under constants. Depending on the event the geocubes API will deliver different parameters to your function. They are described further below.
|
constants:
var GC_CB_ONCREATEPOINT; // event if point marker is created
var GC_CB_POINTCLICK; // onclick event on single points
var GC_CB_POINTMOUSEOVER; // mouseover event on single points
var GC_CB_POINTMOUSEOUT; // mouseout event on single points
var GC_CB_CLUSTERCLICK; // onclick event on cube clusters
var GC_CB_CLUSTERMOUSEOVER; // mouseover event on cube clusters
var GC_CB_CLUSTERMOUSEOUT; // mouseout event on cube clusters
var GC_CB_ONCREATECLUSTER; // event if cube cluster marker is created
var GC_CB_CLUSTERCLICK_RAW; // same as GC_CB_CLUSTERCLICK but without zooming
// you can use zoomIn() to include the zooming
var GC_CB_CLOUDCLICK; // onclick event on cloud clusters
var GC_CB_CLOUDMOUSEOVER; // mouseover event on cloud clusters
var GC_CB_CLOUDMOUSEOUT; // mouseout event on cloud clusters
var GC_CB_ONCREATECLOUD; // event if cloud cluster marker is created
var GC_CB_CLOUDCLICK_RAW; // same as GC_CB_CLOUDCLICK but without zooming
// you can use zoomIn() to include the zooming
var GC_CB_ONLOADSTART; // if user move or zoom with map this is called
var GC_CB_ONLOADEND; // if all points are fetched and shown on the map
|
Parameters that the API delivers to your callback function:
/*
* Events on map
*
* no parameters
*/
// if user move or zoom map this is called
gcGridObj.setCallback(GC_CB_ONLOADSTART, function ()
{
...code... (loading starts)
});
// if all points are fetched and shown on the map
gcGridObj.setCallback(GC_CB_ONLOADEND, function ()
{
...code... (loading ends)
});
/*
* Events on points
*
* marker: GMarker object. to retrieve the coordinates of a
* single point use this object ( marker.getLatLng() )
*
* point_id: this is the unique id you set for the point
*
* following fields can be optionally set on adding points
* with the API
* freetext: 255 bytes text field
* opt_field1: 1st. optional integer field (32 Bit signed)
* opt_field2: 2nd. optional integer field (32 Bit signed)
*/
// onclick event on single points
gcGridObj.setCallback(GC_CB_POINTCLICK, function (GMarker marker, int point_id,
string freetext, int opt_field1, int opt_field2)
{
...code...
});
// mouseover event on single points
gcGridObj.setCallback(GC_IC_POINTMOUSEOVER, function (GMarker marker, int point_id,
string freetext, int opt_field1, int opt_field2)
{
...code...
});
// mouseout event on single points
gcGridObj.setCallback(GC_CB_POINTMOUSEOUT, function (GMarker marker, int point_id,
string freetext, int opt_field1, int opt_field2)
{
...code...
});
// event if point marker is created
gcGridObj.setCallback(GC_CB_ONCREATEPOINT, function (GMarker marker, int point_id,
string freetext, int opt_field1, int opt_field2)
{
...code...
});
/*
* Events on cube clusters
* marker: GCCluster object
* double latNE, lngNE, latSW, lngSW: bound coordinates of cluster
*/
// onclick event on clusters
gcGridObj.setCallback(GC_CB_CLUSTERCLICK, function (GCCluster marker, GLatLng NE, GLatLng SW)
{
...code...
});
// mouseover event on clusters
gcGridObj.setCallback(GC_CB_CLUSTERMOUSEOVER, function (GCCluster marker,
GLatLng NE, GLatLng SW)
{
...code...
});
// mouseout event on clusters
gcGridObj.setCallback(GC_CB_CLUSTERMOUSEOUT, function (GCCluster marker,
GLatLng NE, GLatLng SW)
{
...code...
});
// event if cluster marker is created
gcGridObj.setCallback(GC_CB_ONCREATECLUSTER, function (GCCluster marker,
GLatLng NE, GLatLng SW)
{
...code...
});
/*
* Events on cloud clusters
* marker: GCCluster object
* double latNE, lngNE, latSW, lngSW: bound coordinates of cluster
*/
// onclick event on clusters
gcGridObj.setCallback(GC_CB_CLOUDCLICK, function (GCCluster marker, GLatLng NE, GLatLng SW)
{
...code...
});
// events for clouds and cubes are the same, you only have to change
// the type (GC_CB_CLUSTERCLICK / GC_CB_CLOUDCLICK)
|
Example:
gcGridObj.setCallback(GC_CB_POINTCLICK, function (marker, point_id) {
window.open("http://my.example.com/my_data.html?pid=" + point_id);
});
|
|
|
Function:
function orFilter (int field, int operator, int value) function orFilterRelease(int field, int operator, int value)
|
Description:
Function orFilter means that one of these values can occur, if you set more than ones. orFilterRelease releases the filters that you set before.
|
Parameters:
int field:
GC_FD1
GC_FD2
These are the two optional integer Fields from the
client Library, which you can set, if you add a point.
int operator:
GC_EQ - means "field" have to be equal "value"
int value:
32 Bit signed integer. That is the value which is compared to
the optional fields (int field) in our Database.
|
Example:
var gcGridObj = new geocubes(map, key);
...code...
// show all geo-points where optional field1 (f1) is 33 OR 54 OR 128
gcGridObj.orFilter(GC_FD1, GC_EQ, 33);
gcGridObj.orFilter(GC_FD1, GC_EQ, 54);
gcGridObj.orFilter(GC_FD1, GC_EQ, 128);
gcGridObj.renderFilter();
// release filters after 5 seconds
window.setTimeout(function () {
gcGridObj.orFilterRelease(GC_FD1, GC_EQ, 33);
gcGridObj.orFilterRelease(GC_FD1, GC_EQ, 54);
gcGridObj.orFilterRelease(GC_FD1, GC_EQ, 128);
gcGridObj.renderFilter();
}, 5000);
...code...
|
|
|
Function:
function andFilter (int field, int operator, int value) function andFilterRelease(int field, int operator, int value)
|
Description:
Function andFilter means that all values must occur. andFilterRelease releases the filters that you set before.
|
Parameters:
int field:
GC_FD1
GC_FD2
These are the two optional integer Fields from the
client Library, which you can set, if you add a point.
int operator:
GC_EQ - means "field" have to be equal "value"
int value:
32 Bit signed integer. That is the value which is compared to
the optional fields (int field) in our Database.
|
Example:
...code...
// show all geo-points where optional field1 (f1) is 12 AND optional field2 (f2) is 8
gcGridObj.andFilter(GC_FD1, GC_EQ, 12);
gcGridObj.andFilter(GC_FD2, GC_EQ, 8);
gcGridObj.renderFilter();
...code...
|
|
|
Function:
function renderFilter (void)
|
Description:
After you set one or more filters you have to call the function renderFilter so that the geocubes overlay on your map is reloaded and the filters become active.
|
Example:
...code...
// set filters
gcGridObj.andFilter(GC_FD1, GC_EQ, 12);
gcGridObj.andFilter(GC_FD2, GC_EQ, 8);
// than render the filters to the map
gcGridObj.renderFilter();
...code...
|
|
|
Function:
function textFilter (string value) function textFilterRelease (void)
|
Description:
Text Filtering for the free text field you can set by the geocubes client library.
It searches all geo-points that CONTAINS "value" in the free text field.
|
Example:
...code...
gcGridObj.textFilter("mykeyword");
// resets text filter after 5 seconds.
window.setTimeout(function() {
gcGridObj.textFilterRelease();
}, 5000);
...code....
|
|
|
Function:
function releaseFilters (void)
|
Description:
To initialize the rendering of clusters and points to your map call this function. Until you call this function your map will be empty but please set all options and callbacks before.
|
Example:
Releases all filters you set by function andFilter, orFilter, textFilter
gcGridObj.releaseFilters();
|
|
|
Function:
function enableRenderGrid (void)
|
Description:
To initialize the rendering of clusters and points to your map call this function. Until you call this function your map will be empty but please set all options and callbacks before.
|
Example:
/*
...call constructor...
...set icons...
...set variables...
...set options...
...set callbacks...
*/
gcGridObj.enableRenderGrid();
|
|
|
Function:
function disableRenderGrid (void)
|
Description:
The function disableRenderGrid deactivates the rendering of clusters and points by geocubes. It will clear your map from all overlays. This function does not destroy or desctruct the geocubes object. To reactivate rendering easily call enableRenderGrid.
|
Example:
// deactivate rendering of clusters and points
gcGridObj.disableRenderGrid();
|
|
|