×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Modifying landmarks in Flash Lite

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Add Abstract. Tidy wiki text)
Line 1: Line 1:
[[Category:Flash Lite]][[Category:Location]]
+
[[Category:Flash Lite]][[Category:Location]][[Category:S60 Platform Services]][[Category:S60 5th Edition]][[Category:Code Examples]][[Category:Symbian]]
 +
{{Abstract|This code snippet demonstrates how to list, edit, and delete Landmarks using the Landmarks Platform Service for Flash Lite supported from S60 5th Edition onwards.}}
 +
 
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= [[Media:FlashLite Modifying Landmarks.zip]]
 
|sourcecode= [[Media:FlashLite Modifying Landmarks.zip]]
Line 5: Line 7:
 
|devices= Nokia 5800 XpressMusic
 
|devices= Nokia 5800 XpressMusic
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|platform= S60 5th Edition
+
|platform= S60 5th Edition and later
 
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
Line 22: Line 24:
 
|author= [[User:Nokia Developer KB]]
 
|author= [[User:Nokia Developer KB]]
 
<!-- The following are not in current metadata -->
 
<!-- The following are not in current metadata -->
|subcategory= Location
 
 
|id= CS001292
 
|id= CS001292
 
}}
 
}}
 
==Overview==
 
 
This code snippet demonstrates how to list, edit, and delete Landmarks using the Landmarks Platform Service for Flash Lite supported from S60 5th Edition onwards.
 
  
 
==Preconditions==
 
==Preconditions==
  
'''Note''': To modify landmarks, the test device needs to have at least one landmark registered.
+
{{Note|To modify landmarks, the test device needs to have at least one landmark registered.}}
  
 
==Source==
 
==Source==
Line 228: Line 225:
 
==Example application==  
 
==Example application==  
  
The following sample application has been tested in the Nokia 5800 XpressMusic (S60 5th Edition, Flash Lite 3.0).
+
The following sample application has been tested in the Nokia 5800 XpressMusic (S60 5th Edition, Flash Lite 3.0): [[File:FlashLite Modifying Landmarks.zip]]
[[File:FlashLite Modifying Landmarks.zip]]
+
  
 
==See also==
 
==See also==
Line 237: Line 233:
 
* [[Importing landmarks in Flash Lite]]  
 
* [[Importing landmarks in Flash Lite]]  
 
* [[Exporting landmarks in Flash Lite]]
 
* [[Exporting landmarks in Flash Lite]]
 
 
[[Category:S60 Platform Services]][[Category:S60 5th Edition]]
 
[[Category:Code Examples]][[Category:Code Snippet]]
 

Revision as of 07:35, 3 October 2012

This code snippet demonstrates how to list, edit, and delete Landmarks using the Landmarks Platform Service for Flash Lite supported from S60 5th Edition onwards.

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition and later
Symbian
S60 5th Edition
Article
Keywords: Service.Landmarks, landmark.GetList(), landmark.Add(), landmark.Delete()
Created: User:Nokia Developer KB (26 Jan 2009)
Last edited: hamishwillee (03 Oct 2012)

Contents

Preconditions

Note.pngNote: To modify landmarks, the test device needs to have at least one landmark registered.

Source

// Import Platform Service Interface
import com.nokia.lib.Service;
// Heading of the application
heading_txt.text = "Modifying landmarks";
 
// Define Arrays for information of landmarks
var idList:Array = new Array();
var landmarkList:Array = new Array();
var longitudeList:Array = new Array();
var latitudeList:Array = new Array();
 
var i = 0;
 
// Create new Service object which has Landmark information
var landmark = new Service("Service.Landmarks", "IDataSource");
 
// Get list of the landmarks
listLandmarks();
// Define number of the last item
var lastItem = idList.length-1;
// Trace information of the landmark to the inputs
setTexts();
 
 
/**********************************************************
** Function for setting the texts to inputs
**********************************************************/

function setTexts() {
nro_txt.text = i+1+"/"+idList.length;
 
if(landmarkList[i] == undefined) {
landmark_txt.text = "";
} else {
landmark_txt.text = landmarkList[i];
};
 
if(longitudeList[i] == undefined) {
longitude_txt.text = "";
} else {
longitude_txt.text = longitudeList[i];
};
 
if(latitudeList[i] == undefined) {
latitude_txt.text = "";
} else {
latitude_txt.text = latitudeList[i];
};
};
 
/**********************************************************
** Function for getting updated list of the landmarks
**********************************************************/

function listLandmarks() {
// Define input parameters
var inParams = {Type:"Landmark"};
 
// Define result value
var outParams = landmark.GetList(inParams);
 
// Check if getting the list success
if (outParams.ErrorCode == 0) {
outList = outParams.ReturnValue;
outputEntry = null;
// Format arrays
idList = [];
landmarkList = [];
longitudeList = [];
latitudeList = [];
do {
outputEntry = outList.next();
if (null != outputEntry) {
// Get the lists of IDs and landmark information to Arrays
idList.push(outputEntry.id);
landmarkList.push(outputEntry.LandmarkName);
longitudeList.push(outputEntry.LandmarkPosition.Longitude);
latitudeList.push(outputEntry.LandmarkPosition.Latitude);
} else {
break;
}
} while (true);
} else {
// if errors trace them to the textfield
errorId = outParams.ErrorCode;
error_txt.text = "Error while listing: "+errorId+"\r";
}
}
 
/**********************************************************
** Function for pressing the Edit button.
** Calls Add() method synchronously.
** Edit name and position information of the shown landmark.
**********************************************************/

edit_mc.onPress = function() {
 
// Get ID from the array
var landmarkId = idList[i];
// Get other information from the inputs
var landmarkName = landmark_txt.text;
var lon = longitude_txt.text;
var lat = latitude_txt.text;
var longitude = Number(lon);
var latitude = Number(lat);
 
// Define landmark information
var landmarkPosition = {Longitude:longitude, Latitude:latitude};
var landmarkInfo = {
id:landmarkId, LandmarkName:landmarkName,
LandmarkPosition:landmarkPosition
};
 
// Define input parameters
var inParams = {Type:"Landmark", Data:landmarkInfo};
 
// Define result value
var outParams = landmark.Add(inParams);
if (outParams.ErrorCode == 0) {
error_txt.text = landmarkName+" edited";
}
else {
errorId = outParams.ErrorCode;
error_txt.text = "Error while editing: "+errorId;
};
listLandmarks();
};
 
/**********************************************************
** Function for pressing the Stop button.
** Calls Delete() method synchronously.
** Method deletes the landmark
**********************************************************/

delete_mc.onPress = function() {
var landmarkDeleteId = {id:idList[i]};
var inParams = {Type:"Landmark", Data:landmarkDeleteId};
var outParams = landmark.Delete(inParams);
if (outParams.ErrorCode == 0) {
error_txt.text = landmarkList[i]+" deleted";
}
else {
errorId = outParams.ErrorCode;
error_txt.text = "Error while deleting: "+errorId;
};
listLandmarks();
i = 0;
lastItem = idList.length-1;
setTexts();
};
 
/**********************************************************
** Function for pressing the Prev button
**********************************************************/

prev_mc.onPress = function() {
if(i == 0) {
i = lastItem;
} else {
i--;
};
setTexts();
error_txt.text = "";
};
 
/**********************************************************
** Function for pressing the Next button
**********************************************************/

next_mc.onPress = function() {
if(i == lastItem) {
i = 0;
} else {
i++;
};
setTexts();
error_txt.text = "";
};
 
/**********************************************************
** Function for pressing the Exit button.
**********************************************************/

exit_mc.onPress = function() {
status = fscommand2("Quit");
trace("QUIT");
};

Postconditions

Landmark name, longitude, and latitude information of the device are displayed as inputs. You can edit a landmark by editing input and pressing the Edit button. If there is more than one landmark you can browse them by pressing the Prev and Next buttons. A landmark can be deleted by pressing the Delete button.

Example application

The following sample application has been tested in the Nokia 5800 XpressMusic (S60 5th Edition, Flash Lite 3.0): File:FlashLite Modifying Landmarks.zip

See also

53 page views in the last 30 days.
×