Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Editing Coordinates

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Code ExampleArticle
Created: Paul.Todd (09 Aug 2009)
Last edited: lpvalente (28 Mar 2014)
ID   Creation date August 9, 2009
Platform S60 3rd Edition S60 3rd Edition FP2 and later Tested on devices
Category Symbian C++ Subcategory Location


Contents

Overview

This article provides an example to show how the latitude and longitude coordinates can be edited using GUI. To provide editing facility CAknLocationEditor can be used. See more about CAknLocationEditor here.

CAknLocationEditor provides a means to edit either a latitude coordinate or a longitude coordinate, but not both. To edit both, this control needs to be put into a CAknMultilineDataQueryDialog where the first and second line contain the latitude editor and the longitude editor respectively.

MMP file

The following capabilities and libraries are required:

CAPABILITY none
LIBRARY lbs.lib // for TPosition
LIBRARY avkon.lib // for CAknLocationEditor and CAknMultiLineDataQueryDialog
LIBRARY eikctl.lib eikcoctl.lib uiklaf.lib form.lib

Resource file

The resource file defines the latitude and longitude editors for the data entry dialog. Remember to include eikctl.rsg since this has the definition for R_EIK_LATITUDE_AND_LONGITUDE.

RESOURCE DIALOG r_enter_coordinates_query
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineFirstLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataFirstLocationEd;
label = "Latitude";
control = LATITUDE_EDITOR
{
flags = ELocationEdFlagLatitude;
latlongresourceid = R_EIK_LATITUDE_AND_LONGITUDE;
};
};
},
DLG_LINE
{
type = EAknCtMultilineQuery;
id = EMultilineSecondLine;
control = AVKON_DATA_QUERY
{
layout = EMultiDataSecondLocationEd;
label = "Longitude";
control = LONGITUDE_EDITOR
{
flags = ELocationEdFlagLongitude;
latlongresourceid = R_EIK_LATITUDE_AND_LONGITUDE;
};
};
}
};
}

Source file

To invoke the editor it is then a simple case to just create an instance of the CAknMultiLineDataQueryDialog with the resource from above and a TPosition object and the dialog will be displayed allowing the coordinate to be edited.

   TPosition pos;
pos.SetCoordinate(0.0, 0.0);
CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(pos);
if (dlg->ExecuteLD(R_ENTER_COORDINATES_QUERY))
{
HBufC* latitude = CAknLocationEditor::DisplayableLocationL( pos, CAknLocationEditor::ELatitudeOnly );
CleanupStack::PushL(latitude);
HBufC* longitude = CAknLocationEditor::DisplayableLocationL( pos, CAknLocationEditor::ELongitudeOnly );
CleanupStack::PushL(longitude);
 
TBuf<255> msg;
msg.Format(_L("coordinates were %S %S"), latitude, longitude);
 
CleanupStack::PopAndDestroy(2, latitude);
}

Postconditions

The user can enter and edit a coordinate.


Example code

This page was last modified on 28 March 2014, at 12:21.
51 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×