You Are Here:

Community: Wiki

This page was last modified on 26 January 2009, at 11:02.

CS001292 - Modifying landmarks in Flash Lite

From Forum Nokia Wiki



ID CS001292 Creation date January 26, 2009
Platform S60 5th Edition Tested on devices Nokia 5800 XpressMusic
Category Flash Lite Subcategory Location


Keywords (APIs, classes, methods, functions): Service.Landmarks, landmark.GetList(), landmark.Add(), landmark.Delete()

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

Note: 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

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fAccessingE5fsystemE5fresourcesE5fwithE5fPyS60E5fonE5fS60E5f3rdE5fE45ditionE5fdevicesX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZflashQ qfnZtopicQUqfnTopicZflashE5fliteQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ