×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Google Maps Example

    Hi there,

    I have to access Google Maps in a midlet so I started reading about it here in Nokia's Forum. This wiki has a code example to do it, but when I copy this code and paste it on my project, my IDE (Netbeans 6.8) shows me two errors:

    1 - Line 97 and 98: cannot find method forDigit(int, int) in class java.lang.Character

    2 - Cannot find ArrayList (this one I solved putting a Vector instead of an ArrayList, but I'm wondering why is there an ArrayList in the code if Java ME does not have ArrayList)

    Error number 1 I couldn't solve.

    Can anyone help?

    Thanks in advance,
    Bruno Krebs

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Google Maps Example

    Someone has "improved" the wiki article... bear with me, I'll try to fix it...

    Graham.

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Google Maps Example

    OK, I think I've undone the erroneous changes. I haven't tested it, so can you let me know here, please, if it works OK?

    Cheers,
    Graham.

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Re: Google Maps Example

    Perfect!

    Thank you very much.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Re: Google Maps Example

    Ok, actually I think it's not working that perfect

    The problem is in the urlEncode method more precesily. When I put the name of my city and the country ("Porto Alegre, Brazil") it returns:

    PortoAlegre razil

    and I think it should return something like:

    PortoAlegre,Brazil

    I wish I could fix this method to contribute, but in this very moment I don´t understand exactly this code:

    for (int i = 2; i < bytes.length; i++) {
    byte b = bytes[i];
    if (URL_UNRESERVED.indexOf(b) >= 0) {
    buf.append((char) b);
    } else {
    buf.append('%').append(HEX[(b >> 4) & 0x0f]).append(HEX[b & 0x0f]);
    }
    }
    Sorry for the wrong approval before, I got excited with the map in the screen

  6. #6
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Re: Google Maps Example

    Sorry again, my mistake, I guess it working lol

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Google Maps Example

    You should get:

    Code:
    Porto%20Alegre%2C%20Brazil
    Characters (like ' ' and ',') that are not allowed in URLs should be encoded as %xx, where xx are the character's code in hex.

    I seem to remember that some devices behave oddly if you System.out.println() a string that contains the "%" character. So you might see strange output.

    Thanks for checking this. I undid some changes made since I last editted it, but not others - some of the changes were good. Hopefully I got the right ones! As you correctly pointed out, there is no ArrayList class, and Character has no forDigit() method, in CLDC. Someone had changed the code and not checked it compiled properly!

    Graham.

Similar Threads

  1. Events in google maps
    By madhukv in forum Mobile Java General
    Replies: 5
    Last Post: 2009-11-06, 09:08
  2. [Moved} Google Maps: start from contacts
    By st.b in forum General Development Questions
    Replies: 0
    Last Post: 2008-11-06, 10:31

Posting Permissions

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