Add new MapPoint code for geolocation, Thingy searching and indexing and a macro for rendering thing data outside of the Thingy.
This commit is contained in:
parent
944c76040a
commit
61534779d5
24 changed files with 1442 additions and 176 deletions
167
www/extras/yui-webgui/build/map/map.js
vendored
167
www/extras/yui-webgui/build/map/map.js
vendored
|
|
@ -14,15 +14,15 @@ WebGUI.Map.markers = {};
|
|||
WebGUI.Map.loadingDialog = undefined;
|
||||
|
||||
/**
|
||||
* WebGUI.Map.deletePoint( map, mgr, marker )
|
||||
* Delete a point from the map.
|
||||
* NOTE: We assume the user has already confirmed this action
|
||||
*/
|
||||
* WebGUI.Map.deletePoint( map, mgr, marker )
|
||||
* Delete a point from the map.
|
||||
* NOTE: We assume the user has already confirmed this action
|
||||
*/
|
||||
WebGUI.Map.deletePoint
|
||||
= function ( map, mgr, marker ) {
|
||||
var callback = function ( text, code ) {
|
||||
var callback = function ( text, code ) {
|
||||
WebGUI.Map.hideLoading();
|
||||
var response = YAHOO.lang.JSON.parse( text );
|
||||
var response = YAHOO.lang.JSON.parse( text );
|
||||
// remove the marker from the map
|
||||
if ( !response.error ) {
|
||||
mgr.removeMarker( marker );
|
||||
|
|
@ -34,11 +34,11 @@ WebGUI.Map.deletePoint
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.editPoint( map, mgr, marker )
|
||||
* Edit a point on the map.
|
||||
* up the edit box. mgr is the Marker Manager to add the marker
|
||||
* to.
|
||||
*/
|
||||
* WebGUI.Map.editPoint( map, mgr, marker )
|
||||
* Edit a point on the map.
|
||||
* up the edit box. mgr is the Marker Manager to add the marker
|
||||
* to.
|
||||
*/
|
||||
WebGUI.Map.editPoint
|
||||
= function ( map, mgr, marker ) {
|
||||
var assetId = '';
|
||||
|
|
@ -49,8 +49,8 @@ WebGUI.Map.editPoint
|
|||
marker.map = map;
|
||||
mgr.addMarker( marker, 0 );
|
||||
mgr.refresh();
|
||||
assetId = "new";
|
||||
marker.assetId = "new";
|
||||
assetId = "new";
|
||||
marker.assetId = "new";
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
|
|
@ -60,7 +60,7 @@ WebGUI.Map.editPoint
|
|||
}
|
||||
|
||||
// Callback should open the window with the form
|
||||
var callback = function (text, code) {
|
||||
var callback = function (text, code) {
|
||||
YAHOO.util.Dom.addClass( document.body, "yui-skin-sam" );
|
||||
var dialog = new YAHOO.widget.Dialog("editPoint");
|
||||
|
||||
|
|
@ -81,9 +81,9 @@ WebGUI.Map.editPoint
|
|||
this.submit();
|
||||
}
|
||||
|
||||
var myButtons = [
|
||||
var myButtons = [
|
||||
{ text:"Submit", handler:handleSubmit, isDefault:true },
|
||||
{ text:"Cancel", handler:handleCancel }
|
||||
{ text:"Cancel", handler:handleCancel }
|
||||
];
|
||||
dialog.cfg.queueProperty("buttons", myButtons);
|
||||
dialog.cfg.queueProperty("constraintoviewport", true);
|
||||
|
|
@ -95,37 +95,37 @@ WebGUI.Map.editPoint
|
|||
dialog.callback = {
|
||||
upload: function (o) {
|
||||
// Update marker info
|
||||
var point = YAHOO.lang.JSON.parse( o.responseText );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
var point = YAHOO.lang.JSON.parse( o.responseText );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
GEvent.clearListeners( marker, "click" );
|
||||
GEvent.clearListeners( marker, "infowindowbeforeclose" );
|
||||
|
||||
// Decode HTML entities because JSON is being returned as text/html
|
||||
// See WebGUI::Asset::Wobject::Map www_ajaxEditPointSave
|
||||
var decoder = document.createElement( "textarea" );
|
||||
decoder.innerHTML = point.content;
|
||||
point.content = decoder.value;
|
||||
decoder.innerHTML = point.content;
|
||||
point.content = decoder.value;
|
||||
|
||||
var infoWin = document.createElement( "div" );
|
||||
infoWin.innerHTML = point.content;
|
||||
marker.infoWin = infoWin;
|
||||
infoWin.innerHTML = point.content;
|
||||
marker.infoWin = infoWin;
|
||||
|
||||
if ( point.canEdit ) {
|
||||
var divButton = document.createElement('div');
|
||||
if ( point.canEdit == 1 ) {
|
||||
var divButton = document.createElement('div');
|
||||
infoWin.appendChild( divButton );
|
||||
|
||||
var editButton = document.createElement("input");
|
||||
editButton.type = "button";
|
||||
editButton.value = "Edit";
|
||||
var editButton = document.createElement("input");
|
||||
editButton.type = "button";
|
||||
editButton.value = "Edit";
|
||||
GEvent.addDomListener( editButton, "click", function () {
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
} );
|
||||
divButton.appendChild( editButton );
|
||||
|
||||
var deleteButton = document.createElement("input");
|
||||
deleteButton.type = "button";
|
||||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
var deleteButton = document.createElement("input");
|
||||
deleteButton.type = "button";
|
||||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
GEvent.addDomListener( deleteButton, "click", function () {
|
||||
if ( confirm("Are you sure you want to delete this point?") ) {
|
||||
WebGUI.Map.deletePoint( map, mgr, marker );
|
||||
|
|
@ -134,9 +134,19 @@ WebGUI.Map.editPoint
|
|||
divButton.appendChild( deleteButton );
|
||||
}
|
||||
marker.bindInfoWindow( infoWin );
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
if( point.isGeocoded == 1 ) {
|
||||
//Move the marker to the right location
|
||||
mgr.removeMarker( marker );
|
||||
marker.setLatLng(new GLatLng( point.latitude, point.longitude ));
|
||||
marker.disableDragging();
|
||||
mgr.addMarker(marker,0);
|
||||
}
|
||||
else {
|
||||
marker.enableDragging();
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
}
|
||||
WebGUI.Map.hideLoading();
|
||||
|
||||
WebGUI.Map.markers[map.assetId][marker.assetId] = marker;
|
||||
|
|
@ -156,9 +166,9 @@ WebGUI.Map.editPoint
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.focusOn( pointId )
|
||||
* Pan the appropriate map to view the appropriate map point
|
||||
*/
|
||||
* WebGUI.Map.focusOn( pointId )
|
||||
* Pan the appropriate map to view the appropriate map point
|
||||
*/
|
||||
WebGUI.Map.focusOn
|
||||
= function ( pointId ) {
|
||||
var marker;
|
||||
|
|
@ -169,7 +179,7 @@ WebGUI.Map.focusOn
|
|||
}
|
||||
}
|
||||
if ( !marker ) return;
|
||||
var map = marker.map;
|
||||
var map = marker.map;
|
||||
var infoWin = marker.infoWin;
|
||||
if ( map.getZoom() <= 4 ) {
|
||||
map.setZoom(5);
|
||||
|
|
@ -184,9 +194,9 @@ WebGUI.Map.hideLoading
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.preparePoints ( map, mgr, points )
|
||||
* Prepare the points from WebGUI into Google Map GMarkers
|
||||
*/
|
||||
* WebGUI.Map.preparePoints ( map, mgr, points )
|
||||
* Prepare the points from WebGUI into Google Map GMarkers
|
||||
*/
|
||||
WebGUI.Map.preparePoints
|
||||
= function ( map, mgr, points ) {
|
||||
WebGUI.Map.markers[map.assetId] = {};
|
||||
|
|
@ -196,34 +206,35 @@ WebGUI.Map.preparePoints
|
|||
for ( var i = 0; i < points.length; i++ ) (function(i){ // Create closure for callbacks
|
||||
var point = points[i];
|
||||
var latlng = new GLatLng( point.latitude, point.longitude );
|
||||
var marker = new GMarker( latlng, {
|
||||
title: point.title,
|
||||
draggable: point.canEdit
|
||||
var canDrag = (point.canEdit == 1 && point.isGeocoded == 0) ? true : false;
|
||||
var marker = new GMarker( latlng, {
|
||||
title: point.title,
|
||||
draggable: canDrag
|
||||
} );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
marker.map = map;
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
marker.map = map;
|
||||
|
||||
// Create info window
|
||||
var infoWin = document.createElement( "div" );
|
||||
infoWin.innerHTML = point.content;
|
||||
marker.infoWin = infoWin;
|
||||
infoWin.innerHTML = point.content;
|
||||
marker.infoWin = infoWin;
|
||||
|
||||
// Make editable features
|
||||
if ( point.canEdit ) {
|
||||
var divButton = document.createElement('div');
|
||||
var divButton = document.createElement('div');
|
||||
|
||||
var editButton = document.createElement("input");
|
||||
editButton.type = "button";
|
||||
editButton.value = "Edit"; // Replace with i18n
|
||||
var editButton = document.createElement("input");
|
||||
editButton.type = "button";
|
||||
editButton.value = "Edit"; // Replace with i18n
|
||||
GEvent.addDomListener( editButton, "click", function () {
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
} );
|
||||
divButton.appendChild( editButton );
|
||||
|
||||
var deleteButton = document.createElement("input");
|
||||
deleteButton.type = "button";
|
||||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
var deleteButton = document.createElement("input");
|
||||
deleteButton.type = "button";
|
||||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
GEvent.addDomListener( deleteButton, "click", function () {
|
||||
if ( confirm("Are you sure you want to delete this point?") ) {
|
||||
WebGUI.Map.deletePoint( map, mgr, marker );
|
||||
|
|
@ -248,16 +259,16 @@ WebGUI.Map.preparePoints
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.setCenter ( map, baseUrl )
|
||||
* Set the new center point and zoom level of the map.
|
||||
* map is the Google Map object
|
||||
* baseUrl is the base URL to the Map asset
|
||||
*/
|
||||
* WebGUI.Map.setCenter ( map, baseUrl )
|
||||
* Set the new center point and zoom level of the map.
|
||||
* map is the Google Map object
|
||||
* baseUrl is the base URL to the Map asset
|
||||
*/
|
||||
WebGUI.Map.setCenter
|
||||
= function ( map, baseUrl ) {
|
||||
var url = baseUrl + '?func=ajaxSetCenter';
|
||||
var center = map.getCenter();
|
||||
url = url + ';startLatitude=' + center.lat()
|
||||
var url = baseUrl + '?func=ajaxSetCenter';
|
||||
var center = map.getCenter();
|
||||
url = url + ';startLatitude=' + center.lat()
|
||||
+ ';startLongitude=' + center.lng()
|
||||
+ ';startZoom=' + map.getZoom()
|
||||
;
|
||||
|
|
@ -270,9 +281,9 @@ WebGUI.Map.setCenter
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.setPointLocation( marker, latlng )
|
||||
* Update the point's location in the database.
|
||||
*/
|
||||
* WebGUI.Map.setPointLocation( marker, latlng )
|
||||
* Update the point's location in the database.
|
||||
*/
|
||||
WebGUI.Map.setPointLocation
|
||||
= function ( marker, latlng ) {
|
||||
var url = marker.map.url + '?func=ajaxSetPointLocation'
|
||||
|
|
@ -292,14 +303,14 @@ WebGUI.Map.showLoading
|
|||
= function () {
|
||||
// Create a loading dialog
|
||||
if ( !WebGUI.Map.loadingDialog ) {
|
||||
var loadingDialog = new YAHOO.widget.Panel("loading", { width:"240px",
|
||||
fixedcenter:true,
|
||||
close:false,
|
||||
draggable:false,
|
||||
var loadingDialog = new YAHOO.widget.Panel("loading", { width:"240px",
|
||||
fixedcenter:true,
|
||||
close:false,
|
||||
draggable:false,
|
||||
zindex:4,
|
||||
modal:true,
|
||||
visible:false
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
loadingDialog.setHeader("Loading, please wait...");
|
||||
|
|
@ -314,7 +325,7 @@ WebGUI.Map.showLoading
|
|||
|
||||
WebGUI.Map.updateSelectPoint
|
||||
= function (map) {
|
||||
var select = document.getElementById( 'selectPoint_' + map.assetId );
|
||||
var select = document.getElementById( 'selectPoint_' + map.assetId );
|
||||
if ( !select) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -325,14 +336,14 @@ WebGUI.Map.updateSelectPoint
|
|||
}
|
||||
|
||||
var markers = WebGUI.Map.markers[map.assetId];
|
||||
var sorted = [];
|
||||
var sorted = [];
|
||||
for ( var pointId in markers ) {
|
||||
sorted.push( pointId );
|
||||
}
|
||||
|
||||
sorted.sort( function (a,b) {
|
||||
var ma = WebGUI.Map.markers[map.assetId][a];
|
||||
var mb = WebGUI.Map.markers[map.assetId][b];
|
||||
sorted.sort( function (a,b) {
|
||||
var ma = WebGUI.Map.markers[map.assetId][a];
|
||||
var mb = WebGUI.Map.markers[map.assetId][b];
|
||||
|
||||
if ( ma.title > mb.title ) { return 1; }
|
||||
else if ( ma.title < mb.title ) { return -1; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue