Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 4 of 4

findAdressResults with Java pb

This is a discussion on findAdressResults with Java pb within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi everybody, I'm working on a java application using Mappoint and I have a problem with the "findAdressResults" method here ...

  1. #1
    wissam114 is offline Junior Member White Belt
    Join Date
    Mar 2007
    Posts
    2

    findAdressResults with Java pb

    Hi everybody,

    I'm working on a java application using Mappoint and I have a problem with the "findAdressResults" method here is the code i wrote, but I don't know how to retrieve the location result:
    Code:
     
    FindResults fr;
    Integer geousa=new Integer(MNPA83.GeoCountry.geoCountryUnitedStates);
    Location objLoc1;
    Variant index =new Variant(com.borland.dx.dataset.Variant.INT);
    index.setInt(1);
    fr=objMap.findAddressResults("359 WABASH AVE","BUFFALO"," ","NY","14217",geousa);
    int nbfound=fr.getCount();
    objLoc1=(Location)fr.getItem(index);
    When I debug the program the variable nbfound=1, but I have an "java.lang.ClassCastException" for the last line of the code.
    Please help me to correct the Error if you can,
    Thanks in advance.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: findAdressResults with Java pb

    Hi,

    All items of the collection are not nececarly Location objects. The collection can have other types of object in it also. Possible that is the course for the exception. So you have to check first the type of the item before typecasting it.

  3. #3
    wissam114 is offline Junior Member White Belt
    Join Date
    Mar 2007
    Posts
    2

    Re: findAdressResults with Java pb

    Thanks Wilfried for your reply, The result's type is "stdobjref" so to solve the pb I replaced the Cast instruction by the following:

    Code:
     
    objLoc1= new Location(fr.getItem(index));
    and I had the object Location I need.
    If you have any other Solution please let me know.
    Thanks again.

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: findAdressResults with Java pb

    Hi,

    Yes will sure work if the returned item is a Location object, but what if it is a Pushpin or other object, then it will generate an exception.

    I'm no Java specialist but maybe first store it in a new object, this will always work, then get the class of it and if it is a Location then I think you can typecast it. Something like this:

    Object o = new Object(fr.getItem(index));
    o.getClass() or o.isInstance() or o.getClass.getName()

    I'm not sure if this will get you further.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Mappoint java support
    By Anonymous in forum Bing Maps and MapPoint Web Service
    Replies: 9
    Last Post: 02-20-2009, 01:28 AM
  2. mappoint cd development in java?
    By nprimex1 in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 03-23-2006, 12:18 PM
  3. java issue
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-01-2005, 06:11 PM
  4. compatibility java and asp
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 04-19-2004, 12:03 PM
  5. something like mappoint, but for java...
    By Joeba in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 12-03-2002, 10:14 AM

Tags for this Thread

Posting Permissions

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66