PDA

View Full Version : Open a map of a special address with Delphi



Rita P.
02-05-2003, 10:55 AM
Hi,

I'm new in working with MapPoint and I'm a bit amazed that there's so less information about programming MapPoint with Delphi. So I hope I can get some general information here.
In my address-database I would like to integrate a detailed map of this address. That meens I would like to show the map on a Delphi-Sheet after I opened the special address dataset.
Until now I use an OleContainer to show the map.
I already found some programming-information but only in VB. Could anybody tell me how I can act further?

Thanks.

Kind regards
Rita

rbarthels
02-07-2003, 02:28 AM
Hi Rita,

your are right. There is no much information concerning Delphi and MapPoint. So you must be familiar with COM and then you can understand the VB examples and convert them to Delphi.

So far I have done a lot with MapPoint in Delphi. If you have problems you can ask me and I could send you examples of my code.

Regards
Rainer

Rita P.
02-07-2003, 03:05 AM
Hi Reiner,

thanks for your reply.
I already wrote in my first posting what I would like to do with MapPoint and Delphi. Once again...
When I open my address-dataset a window is shown with lots of information about this address. Now I still have another sheet where I would like to display a map (with MapPoint) where the area of this address is shown.
Do I have to use the AddPushpin Method? How can I use this in Delphi?
Until now I use the following code to show the map of Europe.



procedure TTWCAxAddressFormSDK.TS_MapGISShow(Sender: TObject);
var vGuid : TGuid;
FMap : _Map;
begin
OleContainer_Map.CreateObject('MapPoint.Map.EU.9', FALSE );
OleContainer_Map.DoVerb(1);
OleContainer_Map.OleObjectInterface.GetUserClassID (vGuid);
FMap := IDispatch(OleContainer_Map.OleObject) as _Map;

end;



Thanks for your help.

Rita

Rita P.
02-07-2003, 03:07 AM
Sorry, Rainer, for writing your name in a wrong way!!!

Rita

rbarthels
02-10-2003, 05:02 PM
Hi Rita,

here is some code for showing an address in a map. You get a FindResult-collection from FMap.FindAdressResults. Then you have a location
which you can use with Goto_. The problem is when you get
an geoNoGoodResult. Then I try to choose the one which fits the best.

procedure doAddressSearch(aCountry:GeoCountry; aZIP:WideString; aCity:WideString; aStreet:WideString);
var
i:integer;
aLocation:Location;
index:OleVariant;
aFindResults:FindResults;
aStreetAddress: StreetAddress;
begin
if FMap=NIL then
exit;

aFindResults:=FMap.FindAddressResults(aStreet,aCit y,'','', aZIP, aCountry);

if aFindResults.Count<=0 then
exit;

index:=1;
if aFindResults.Get_ResultsQuality=geoNoGoodResult then
begin
for i:=1 to aFindResults.Count do
begin
aLocation:=aFindResults.Item[index] as Location;
aStreetAddress:= aLocation.StreetAddress;
index:=index+1;

bContinue:=False;
if aStreetAddress<>NIL then bContinue:=True;
if aLocation.Type_=geoShowByPostal1 then bContinue:=True;
if aLocation.Type_=geoShowByPostal2 then bContinue:=True;
if aLocation.Type_=geoShowByPostal3 then bContinue:=True;
if aLocation.Type_=geoShowByPostal4 then bContinue:=True;
if aLocation.Type_=geoShowByCity then bContinue:=True;
if bContinue=False then
continue;

if (aStreetAddress<>NIL) and (aZIP<>aStreetAddress.PostalCode) then
continue;

aLocation.GoTo_;
exit;
end;
end else
begin
aLocation:=aFindResults.Item[index] as Location;
aLocation.GoTo_;
end;
end;

I hope there isn't an error in that code because I take the original one
and deleted some lines.

Rainer