×

Discussion Board

Results 1 to 9 of 9

Thread: Mopymaps

  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Question Mopymaps

    Hi

    I am testing the example 88 of the book of Jürgen Sheible (mopymaps) but so far without success, I believe that has something wrong with the segunte piece of code.


    # Is URL of the service
    MAP_URL = ?????

    .....

    addr = appuifw.query(u"Address:", "text")
    if not addr:
    return
    params = ("location" : addr,
    "appid" : APP_ID,
    "image_type" : "png",
    "image_height" : "600",
    "image-width" : "600",
    "zoom" : "6")
    show_text(u"Loading map...")
    try:
    url = MAP_URL + urllib.urlencode(params)
    res = urllib.urlopen(url).read()
    except:
    show_text(u"Network error")
    return

    ....

    Thank you for your help.
    aldo silva
    ---------------------------
    http://www.inphormatica.com

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Mopymaps

    Quote Originally Posted by aldosilva View Post
    Hi

    I am testing the example 88 of the book of Jürgen Sheible (mopymaps) but so far without success, I believe that has something wrong with the segunte piece of code.

    hello aldosilva

    i have earlier checked this code in my N95 8gb and it was working like a charm. May be the problem is with your connectivity.

    BTW are you getting any sort of errors???

    Enjoy Pythoning
    Gaba88

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Mopymaps

    Quote Originally Posted by aldosilva View Post
    Hi

    I am testing the example 88 of the book of Jürgen Sheible (mopymaps) but so far without success, I believe that has something wrong with the segunte piece of code.


    # Is URL of the service
    MAP_URL = ?????

    .....

    addr = appuifw.query(u"Address:", "text")
    if not addr:
    return
    params = ("location" : addr,
    "appid" : APP_ID,
    "image_type" : "png",
    "image_height" : "600",
    "image-width" : "600",
    "zoom" : "6")
    show_text(u"Loading map...")
    try:
    url = MAP_URL + urllib.urlencode(params)
    res = urllib.urlopen(url).read()
    except:
    show_text(u"Network error")
    return

    ....

    Thank you for your help.
    You are supposed to write the URL there. Without assigning the url to the variable, the code would not work.
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: Mopymaps

    I'm assigning this value to the url.

    http://maps.google.com/maps/geo
    aldo silva
    ---------------------------
    http://www.inphormatica.com

  5. #5
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Mopymaps

    Quote Originally Posted by aldosilva View Post
    I'm assigning this value to the url.

    http://maps.google.com/maps/geo
    AFAIK, you should also have an API KEY as a part of your URL, since you do not parse it elsewhere.
    Pankaj Nathani
    www.croozeus.com

  6. #6
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: Mopymaps

    I put the key, my question is if the URL I am passing this correct, because the script responds None after typing the address (addr)
    aldo silva
    ---------------------------
    http://www.inphormatica.com

  7. #7
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: Mopymaps

    Hello Aldo,

    I did a small test here with querie, with success. Code is below:

    Code:
    import urllib
    
    MAP_URL="http://maps.google.com/maps/geo?"
    
    APP_ID = "ABQIAmyapikeyiscodedherepleaseputyourslOf2dqA"
    
    params = {"q": "1600+Amphitheatre+Parkway,+Mountain+View,+CA",
              "key":APP_ID,
              "output":"json",
              "oe":"utf8",
              "sensor":"true"}
    
    print "Loading map..."
    url = MAP_URL + urllib.urlencode(params)
    print url
    res = urllib.urlopen(url).read()
    Output (json output, you may decode it with simplejson)

    Code:
    >>> res
    '{\n  "name": "1600+Amphitheatre+Parkway,+Mountain+View,+CA",\n  "Status": {\n    "code": 200,\n    "request": "geocode"\n  },\n  "Placemark": [ {\n    "id": "p1",\n    "address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",\n    "AddressDetails": {"Country": {"CountryNameCode": "US","CountryName": "USA","AdministrativeArea": {"AdministrativeAreaName": "CA","Locality": {"LocalityName": "Mountain View","Thoroughfare":{"ThoroughfareName": "1600 Amphitheatre Pkwy"},"PostalCode": {"PostalCodeNumber": "94043"}}}},"Accuracy": 8},\n    "ExtendedData": {\n      "LatLonBox": {\n        "north": 37.4251196,\n        "south": 37.4188244,\n        "east": -122.0809954,\n        "west": -122.0872906\n      }\n    },\n    "Point": {\n      "coordinates": [ -122.0841430, 37.4219720, 0 ]\n    }\n  } ]\n}\n'

  8. #8
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Mopymaps

    There you go, APP_ID is included in the URL as parameters.

    Quote Originally Posted by croozeus View Post
    AFAIK, you should also have an API KEY as a part of your URL, since you do not parse it elsewhere.
    Pankaj Nathani
    www.croozeus.com

  9. #9
    Registered User
    Join Date
    Oct 2007
    Location
    Brasil
    Posts
    39

    Re: Mopymaps

    Hi Marcelo,

    I am very busy lately. But this weekend I will again test the application. Thanks for the tip.
    aldo silva
    ---------------------------
    http://www.inphormatica.com

Posting Permissions

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