|
API Reference Home: API Reference Home client access: REST Interface PHP Library geocubes common: Javascript Example Function Overview Quick Links: Defects / Enhancements List Manage Account |
The PHP client library is used to add and remove points from the geocubes server and your map. Download this library and save it to your webserver. You can integrate this library directly into your application. Below you will see an example.
<?php
// require geocubes api class
require_once("geocubesapi.class.php");
/**
* construct the geocubes object
* You will find GEOCUBES_API_KEY and GEOCUBES_API_TOKEN
* under "Manage Account"
**/
$gc = new geocubes("GEOCUBES_API_KEY", "GEOCUBES_API_TOKEN");
/**
* For every point you want to add to geocubes and your map you
* will need to give them an unique id. To simplify matters you can
* use the id's you assigned for your data records in your database.
**/
$unique_id = 12345; // 32 Bit unsigned Integer
$latitude = 53.1337; // Double
$longitude = 13.054999; // Double
$free_text = "my keywords here"; // Limited to 255 Bytes
$opt_field1 = 12; // 32 Bit signed Integer
$opt_field2 = 23; // 32 Bit signed Integer
/*
* addPoint(int unique_id, double latitude, double longitude);
* On success this function returns the unique id of the added geo point.
* If an error occured it returns 0. You should log errors yourself, so you
* can investigate these later.
*/
if ($gc->addPoint($unique_id, $latitude, $longitude, $free_text, $opt_field1, $opt_field2) == 0)
printf("An error is occured\n");
else
printf("Geo Point with Id: %d, Lat: %.10f, Lng: %.10f,
Text: %s, Field1: %d, Field2: %d added\n",
$unique_id, $latitude, $longitude, $free_text, $opt_field1, $opt_field2);
/*
* removePoint(int unique_id);
* On success it returns the unique id of the removed geo point.
* If an error occured it returns 0.
*/
/* remove this comment to try out removing this point
if ($gc->removePoint($unique_id) == 0)
printf("An error occured while removing geo point id: %d\n", $unique_id);
else
printf("Geo point with Id: %d successfully removed\n", $unique_id);
*/
?>
|
|||||||||||||||||||||||
