×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    1

    Unhappy Geocoding on widget.

    Hello everyone...
    I have been struggling with a problem and I hope someone can help me with it. ^^

    I am creating a widget (school assignment) for N97, running on S60 Symbian. The widget is required to take in the current location of the user and convert this variables (lat&lng) to human readable format and display only the address in a separate concept.

    The problem I have right now is the conversion of the derived coordinates..
    I've searched high and low for the right codings to include.

    Does anyone know the codes to have it done?
    PS: A marker is not required for this widget...

    Btw, I use Aptana RadRails Studio, Java Script.

    Regards,
    Jasmine.

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Perth, Western Australia
    Posts
    286

    Smile Re: Geocoding on widget.

    Quote Originally Posted by Jasmean View Post
    Hello everyone...
    I have been struggling with a problem and I hope someone can help me with it. ^^

    I am creating a widget (school assignment) for N97, running on S60 Symbian. The widget is required to take in the current location of the user and convert this variables (lat&lng) to human readable format and display only the address in a separate concept.

    The problem I have right now is the conversion of the derived coordinates..
    I've searched high and low for the right codings to include.

    Does anyone know the codes to have it done?
    PS: A marker is not required for this widget...

    Btw, I use Aptana RadRails Studio, Java Script.

    Regards,
    Jasmine.


    Ok,

    This is how I do it

    function MyLocation() {
    try {
    // This specifies update option used while retrieving location estimation.
    var updateoptions = new Object();
    // Setting PartialUpdates to 'FALSE' ensures that user get atleast
    // BasicLocationInformation (Longitude, Lattitude, and Altitude.)
    updateoptions.PartialUpdates = false;
    updateoptions.UpdateTimeOut = 60000000; //60 000 000 microseconds = 1 minute

    var criteria = new Object();
    criteria.LocationInformationClass = "BasicLocationInformation";
    criteria.Updateoptions = updateoptions;

    var result = so.ILocation.GetLocation(criteria, callbackLocation);
    var errCode = result.ErrorCode;
    if(errCode) {
    alert("(005) GPS Error: " + errCode + " " + result.ErrorMessage);
    }
    }
    catch (e) {
    alert ("(004) ::MyLocation error: " + e);
    }
    }

    //Callback function that receives the result as parameter
    function callbackLocation(transId, eventCode, result)
    {
    var errCode = result.ErrorCode;
    if (errCode) {
    alert("(003) GPS Error: " + errCode + " " + result.ErrorMessage);
    }
    else {
    aLat = result.ReturnValue.Latitude;
    aLon = result.ReturnValue.Longitude;
    var point = new google.maps.LatLng(aLat,aLon);

    var myOptions = {
    zoom: 14,
    navigationControl: true,
    mapTypeControl: false,
    scaleControl: false,
    center: point,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map"), myOptions);
    geocoder = new google.maps.Geocoder();
    ILocation.CancelNotification();
    }

    geocoder.geocode({'latLng': point}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    if (results[0]) {Myaddress = results[0].formatted_address;}
    }
    }

    Hope this helps. It is done with google maps so you need to have a htnl element with and id="map".

    Regards
    Brian Oldfield

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    Zaandam, Holland
    Posts
    71

    Re: Geocoding on widget.

    You're in luck, I did this just yesterday.

    Here's whats up..

    Note: xhttp must be a XMLHttpRequest object, lat is latitude, lon is longitude.

    /* Get Geocode */
    var url = "http://maps.google.com/maps/api/geocode/json?latlng=" + lat + "," + lon + "&sensor=false";
    xhttp.onreadystatechange = function(){
    if (xhttp.readyState == 4) {
    var m = eval('(' + xhttp.responseText + ')');
    alert(m[0]['formatted_address']);
    xhttp = null;
    }
    }
    xhttp.open("GET", url, true);
    xhttp.send(null);

    Stripped out some stuff from my code here cos you obviously only need the basics,
    but you should get the point after this.

    The collected data is in the alert. (There's much more, but to accomodate you, I changed it to the formatted address)

    Enjoy.

Similar Threads

  1. Replies: 0
    Last Post: 2010-01-14, 21:21
  2. Replies: 1
    Last Post: 2009-12-20, 05:28
  3. Problems with widget [links, task icon]
    By smazil in forum Symbian
    Replies: 2
    Last Post: 2009-08-28, 09:45
  4. S60 widget vanishes after reboot
    By el.orson in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-08-26, 14:47
  5. My widget stopped working. Feed read timeout
    By miklos.szanyi@gmail.com in forum Widsets Development
    Replies: 0
    Last Post: 2009-01-23, 10:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×