Namespaces
Variants
Actions

Editing Coordinates

Jump to: navigation, search
MultiMediaTile.png
Article Metadata

Code Example
Article
Created: Paul.Todd (09 Aug 2009)
Last edited: hamishwillee (23 Jul 2012)
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 23 July 2012, at 11:01.
162 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved