Mapwidget

Geo2Tag Map Widget
Geo2Tag Map Widget is a ineractive map, based on Leaflet and Geo2Tag JavaScript client library. Main features:
 * displaying tags on a OpenStreetMaps map
 * channel filtering in UI

How to add Map Widget to your web-page
If you want to add Map Widget to your web page, you need to do following steps:     
 * Download geo2tag_map_widget.js and geo2tag_requests.js (from repo) to your web-server folder, which is accessible by http.
 * Add following code to the head tag of your web-page:


 * Add blank div tag with name map to your web-page:

var mapWidget = new MapWidget(LATITUDE, LONGITUDE, "map"); SettingsStorage.SERVER_URL = http://example.com/service; function onMapWidgetLogin{ mapWidget.filterCircle(latitude, longitude, radius, timeFrom, timeTo); }
 * Initialize Map Widget by the next code (LATITUDE, LONGITUDE - coordinates of the map center) and specify the Geo2Tag server, which you will use :
 * Allow “Access-Control-Allow-Origin:*” headers on the Geo2Tag server status page - use gide by this link
 * Login at Geo2Tag service and get tags:

mapWidget.addEventListener("onLoginSuccess",onMapWidgetLogin); mapWidget.login(login, password);

where timeFrom and timeTo is a time string in next format: date month year hour:minutes:seconds.milliseconds 09 05 2013 02:05:48.356

How to test
Map Widget can be tested localy using https://github.com/geo2tag/mapwidget/blob/master/map.html, or using running instance by this link.

Geo2Tag JavaScript client library
Geo2Tag JavaScript client library is a js file, which contains realizations of basic REST API requests:
 * Login
 * SubscribedChannels
 * AvailableChannels
 * Subscribe
 * Unsubscribe
 * LoadTags
 * WriteTag
 * FilterCircle
 * FilterRectangle
 * FilterPolygon
 * FilterCylinder
 * FilterCube
 * FilterFence

Structure
For each request, mentioned above, there is a function in geo2tag_requests.js, which takes request parameters + two callbacks:


 * onLoadCallback(jsonObject)
 * onErrorCallback(jsonObject)

and performs async call. Both of them recieve request processing result (jsonObject). Use this page for information about its structure. onLoadCallback is called when jsonObject.errno equals zero (means success), in other cases onErrorCallback is called.

Example
This code does login request:

onLoadCallback = function(jsonResponse){ console.log(jsonResponse["auth_token"]); };

onErrorCallback = function(jsonResponse){ console.log("Something went wrong, errno = "+jsonResponse["errno"]); };

sendLoginRequest(login, password, onLoadCallback, onErrorCallback);