MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




findAdressResults with Java pb

This is a discussion on findAdressResults with Java pb within the MapPoint 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 04-13-2007
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 04-14-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 04-14-2007
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 04-14-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/findadressresults-java-pb-5833.html

Posted By For Type Date
Using MapPoint In Delphi - MapPoint Articles - MP2K Magazine This thread Refback 04-22-2007 11:56 AM
Microsoft MapPoint 2006 - MP2K Magazine This thread Refback 04-17-2007 01:59 PM
MapPoint Gets New General Manager - MapPoint News - MP2K Magazine This thread Refback 04-14-2007 09:02 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Mappoint java support Anonymous MapPoint Web Service and Virtual Earth 7 02-20-2007 07:22 AM
mappoint cd development in java? nprimex1 MapPoint 2006/2009 Discussion 2 03-23-2006 11:18 AM
java issue Anonymous MapPoint 2006/2009 Discussion 1 03-01-2005 05:11 PM
compatibility java and asp Anonymous MapPoint 2006/2009 Discussion 3 04-19-2004 11:03 AM
something like mappoint, but for java... Joeba MapPoint 2006/2009 Discussion 2 12-03-2002 09:14 AM


All times are GMT -5. The time now is 02:03 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Canada Ski Holidays
Canada is rich in culture and heritage. It boasts over 41 national parks diverse in wildlife and spectacular scenery. Canada ski holidays offer a truly remarkable ski holiday destination.

Online Travel Agent Uk
UK's Best Travel Agent at the Guardian Unlimited travel awards. We have UK Online Travel Agents free to help with your travel.

Flight to Canada
Book a flight to Canada to explore one of the most exciting travel destinations in the world. There are loads of interesting cities but some even more impressive natural beauty.

Cuba Holidays
Cuba holidays offer an exciting cultural and wonderful culinary experience. Book with The Holiday Place for a great deal.

Cheap Greece Holidays
For cheap Greece holidays make sure you know when to book and who to book with. Visit ulookubook.com to get help with doing both of those things. Why not time your visit with a Greek festival?

Cheap family holidays
To plan cheap family holidays, use Travel.co.uk to explore all the delightful possibilities that there are.

Sharm Holidays
See beautiful Egyptian sites! Info on Sharm holidays, only at On The Beach.


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