plugins/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-4DDE31C7-EC0D-4EEC-BC3A-A0B0351154F8.html
changeset 470 d4809db37847
parent 229 716254ccbcc0
equal deleted inserted replaced
469:4d198a32ac7d 470:d4809db37847
       
     1 
       
     2 <!DOCTYPE html
       
     3   PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
     4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="mobileconcept"/><meta name="DC.Title" content="Accessing device location information"/><meta name="DC.Relation" scheme="URI" content="GUID-CF55DBA3-2D4C-4FD0-8A06-862E6128F4E7"/><meta name="DC.Relation" scheme="URI" content="GUID-D581028C-06ED-422D-866E-AE6C93075084"/><meta name="DC.Relation" scheme="URI" content="GUID-1EFD7043-E9B8-4B4E-9EA6-A20B3EECC14A"/><meta name="DC.Relation" scheme="URI" content="GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-4DDE31C7-EC0D-4EEC-BC3A-A0B0351154F8"/><title>Accessing
       
     5 device location information </title><script type="text/javascript">
       
     6       function initPage() {}
       
     7     </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-4DDE31C7-EC0D-4EEC-BC3A-A0B0351154F8">Accessing
       
     8 device location information</h1><div>
       
     9 <p>The <a href="GUID-53CE4DE6-F065-4339-8C18-5C30A9540053.html#GUID-53CE4DE6-F065-4339-8C18-5C30A9540053">Location
       
    10 Service API</a> allows <span>widgets</span> to retrieve information about
       
    11 the physical location of a device and to perform calculations based on location
       
    12 information. You can use the Location Service to create <span>widgets</span> that
       
    13 provide location-based services (LBS). For example, you can create <span>widgets</span> that:</p>
       
    14 <ul>
       
    15 <li><p>Provide directions to a destination, for example the nearest
       
    16 restaurant</p></li>
       
    17 <li><p>Monitor the locations of snow-plowing vehicles</p></li>
       
    18 <li><p>Calculate distances between geographical locations</p>
       
    19 </li>
       
    20 </ul>
       
    21 <p>The Location Service relies on the GPS capabilities of the device to
       
    22 provide location information. If the device does not include or is not connected
       
    23 to a positioning system, the service cannot provide such information.</p>
       
    24 <div><h3>Accessing the API and supported methods</h3>
       
    25 <p>To create a <a href="GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080.html#GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080">service
       
    26 object</a> for the Location Service API, use <code>Service.Location</code> to
       
    27 identify the service provider and <code>ILocation</code> to identify
       
    28 the supported interface:</p>
       
    29 
       
    30 <pre class="codeblock" id="GUID-AB3999E2-E092-4AD6-A1B3-B601877521F6">var so = device.getServiceObject("Service.Location", "ILocation");</pre>
       
    31 <p>The <code>ILocation</code> interface provides the following
       
    32 methods:</p>
       
    33 <ul>
       
    34 <li><p><a href="GUID-150E440F-56E4-4249-8739-A5A7A2050600.html#GUID-150E440F-56E4-4249-8739-A5A7A2050600"><code>GetLocation()</code></a></p>
       
    35 
       
    36 <p>Use the <code>GetLocation()</code> method to retrieve the current
       
    37 location of the device.</p>
       
    38 
       
    39 </li>
       
    40 <li><p><a href="GUID-7A0190CB-545E-48D2-BAF0-D28E03CDFCA5.html#GUID-7A0190CB-545E-48D2-BAF0-D28E03CDFCA5"><code>Trace()</code></a></p>
       
    41 
       
    42 <p>Use the <code>Trace()</code> method to retrieve periodic updates
       
    43 about the current location of the device.</p>
       
    44 
       
    45 </li>
       
    46 <li><p><a href="GUID-DBEE8177-7246-4FEE-A0F1-D6AEEA6EA206.html#GUID-DBEE8177-7246-4FEE-A0F1-D6AEEA6EA206"><code>Calculate()</code></a></p>
       
    47 
       
    48 <p>Use the <code>Calculate()</code> method to perform mathematical
       
    49 calculations based on a source location and a target location.</p>
       
    50 
       
    51 </li>
       
    52 <li><p><a href="GUID-7A466B60-88DD-4A3A-B64C-E7300D42DA56.html#GUID-7A466B60-88DD-4A3A-B64C-E7300D42DA56"><code>CancelNotification()</code></a></p>
       
    53 
       
    54 <p>Use the <code>CancelNotification()</code> method to cancel an
       
    55 ongoing asynchronous call. This method is valid for any asynchronous call
       
    56 made through the Location Service API.</p>
       
    57 
       
    58 </li>
       
    59 </ul>
       
    60 </div>
       
    61 <div><h3>Using the service in a widget</h3>
       
    62 <p>To access location information using the Location Service API:</p>
       
    63 <ol>
       
    64 <li id="GUID-09408614-B079-437A-BF7C-1580105906C1-GENIDd0e8097"><a name="GUID-09408614-B079-437A-BF7C-1580105906C1-GENIDd0e8097"><!----></a><p>Create a service
       
    65 object for the API using <a href="GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080.html#GUID-04095E9A-50E7-4E5F-BD6F-71DA281A0080"><code>device.getServiceObject()</code></a>.</p>
       
    66 </li>
       
    67 <li id="GUID-C7877560-C290-4E7D-980C-D65D50DC5B4A-GENIDd0e8106"><a name="GUID-C7877560-C290-4E7D-980C-D65D50DC5B4A-GENIDd0e8106"><!----></a><p>Define the
       
    68 tasks you want to perform and choose the correct methods for them.</p>
       
    69 </li>
       
    70 <li id="GUID-C4DFB650-8BAD-4947-AE25-74DFCD52229C-GENIDd0e8111"><a name="GUID-C4DFB650-8BAD-4947-AE25-74DFCD52229C-GENIDd0e8111"><!----></a><p>Optionally,
       
    71 define how you want the results filtered.</p></li>
       
    72 <li id="GUID-03590B36-FFCA-4E39-A781-92080EE16B34-GENIDd0e8115"><a name="GUID-03590B36-FFCA-4E39-A781-92080EE16B34-GENIDd0e8115"><!----></a><p>Define methods
       
    73 for processing the results.</p></li>
       
    74 <li id="GUID-B7AF643B-5587-40D5-A423-0EAF4D3A8DFF-GENIDd0e8119"><a name="GUID-B7AF643B-5587-40D5-A423-0EAF4D3A8DFF-GENIDd0e8119"><!----></a><p>Retrieve the
       
    75 location information using the methods defined in step 2. Use asynchronous
       
    76 methods together with <a href="GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608.html#GUID-C7C3B541-8D28-4DC6-9003-ECF57F26C608"><code>callback()</code></a>.</p>
       
    77 </li>
       
    78 <li id="GUID-76B47850-874B-4F80-9440-DB7E2A2B9477-GENIDd0e8128"><a name="GUID-76B47850-874B-4F80-9440-DB7E2A2B9477-GENIDd0e8128"><!----></a><p>Process the
       
    79 results with the methods defined in step 4.</p></li>
       
    80 </ol>
       
    81 <p>For the complete source of a sample widget that demonstrates how to
       
    82 use this service, see <a href="GUID-620340F8-F844-445E-80AA-71C757320B7E.html#GUID-620340F8-F844-445E-80AA-71C757320B7E">the full example</a>.</p>
       
    83 </div>
       
    84 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html>