MapPoint Forums

MapForums

Community of MapPoint and Virtual Earth Users and Developers




What happens when YOU click on a street?

This is a discussion on What happens when YOU click on a street? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I'm using MP2002 (Europe). When I click on a street I usually get the streetname and postal code for it. ...


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

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-11-2002
Junior Member
White Belt
 
Join Date: Nov 2002
Posts: 10
What happens when YOU click on a street?

I'm using MP2002 (Europe). When I click on a street I usually get the streetname and postal code for it. Somethimes I get the housenumber. However, for streets residing in the Netherlands, I NEVER get the postal code. I would like to know if people experience the same result that I get (no postal codes for the Netherlands). Does anyone know the reason for this?

Any comments are welcome.

Pascal
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 12-11-2002
Junior Member
White Belt
 
Join Date: Dec 2002
Posts: 7
Send a message via ICQ to yelmaci Send a message via MSN to yelmaci
Hi pascal,

See next post
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 12-13-2002
Junior Member
White Belt
 
Join Date: Dec 2002
Posts: 7
Send a message via ICQ to yelmaci Send a message via MSN to yelmaci
Please find here the required function to find NL post codes.

nlpostcodefinder is the main function. Requires 2 parameters.

1st : street name,
2nd: city name.

and returns back the postcode.


Pls: this is just for NL. For other countries, already possible to get the postcode directly via FindAddressResult of location.

Pls: Put 3 edit boxes to a form(formname : form1). names are: city, street,postcode. And lastly, add a button. its name is Button1.


Regards.
----------------------------------------------------------

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, OleServer, MapPoint_TLB;

type
TForm1 = class(TForm)
Map11: TMap1;
street: TEdit;
Label1: TLabel;
city: TEdit;
Label2: TLabel;
Button1: TButton;
postcode: TEdit;
Label5: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
locNorthPole:Location;
locSantaCruz:Location; //Center of western hemisphere
Pi, dblHalfEarth, dblQuarterEarth:double;
function Arccos(x:double):double;
function GetLat(locx:Location):double;
function GetLon(locx:Location):double;
function nlpostcodefinder(pstreet,pcity:string):string;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}
//------------------------------------------
function TForm1.Arccos(x:double):double;
var
ret:double;
begin
if x=1 then
ret:=0
else
ret:=ArcTan(-x/Sqrt(-x*x+1))+2*ArcTan(1);
result:=ret;
end;
//--------------------------------------------

function TForm1.GetLat(locx:Location):double;
var
ret:double;
begin
ret:=90 - 180 * map11.Distance(locNorthPole, locX) / dblHalfEarth;
result:=ret;
end;


function TForm1.GetLon(locx:Location):double;
var
ret, l , d , lat:double;
begin
lat:=GetLat(locx);

d:= map11.Distance(map11.GetLocation(lat, 0, 0), locX);

l:= (Lat / 180) * Pi;

ret:= 180 * Arccos((Cos((d * 2 * Pi) / (2 * dblHalfEarth)) - Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / Pi;

If map11.Distance(locSantaCruz, locX) < dblQuarterEarth Then ret:= -ret;

result:=ret;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
locNorthPole:=map11.GetLocation(90,0,0);
locSantaCruz:=map11.GetLocation(0,-90,0);
dblHalfEarth:=map11.Distance(locNorthPole, map11.GetLocation(-90, 0,0));

dblQuarterEarth:=dblHalfEarth/2;
Pi:=3.14159265358979;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
postcode.Text:=nlpostcodefinder(street.text,city.t ext);
end;

//---------------------
function TForm1.nlpostcodefinder(pstreet,pcity:string):stri ng;
var
street1,city1,postcode1:widestring;
frs,frs2,frs3:findresults;
la,lc,l:location;
nl,o:olevariant;
i:integer;
str,ret1:string;
dist:double;
lat1,long1,lat1x,long1x:double;
label loop1;
begin
ret1:='NotF';
nl:=176;
street1:=pstreet;
city1:=pcity;

frs:=map11.FindAddressResults(street1,city1,'','', '',nl);
if frs.Get_Count>0 then
begin
o:=1;
la:=frs.Get_Item(o) as location;

lat1:=GetLat(la);
long1:=GetLon(la);


//////////////////////////////
l:=map11.GetLocation(lat1,LONG1,0);
dist:=0.5;

loop1:
frs2:=l.FindNearby(dist);


for i:=1 to frs2.Get_Count do
begin
o:=i;
lc:=frs2.Get_Item(o) as Location;

try
str:=lc.StreetAddress.Get_Street;
//-------------------POSTCODE CONTROLL------------------------------
postcode1:=Copy(str,1,4);
if pos(UpperCase(city1),Uppercase(str))>0 then
begin
city1:=Copy(str,6,100);
frs3:=map11.FindAddressResults(street1,city1,'','' ,postcode1,nl);
if frs3.Get_Count>0 then
begin
o:=1;
la:=frs3.Get_Item(o) as location;
lat1x:=GetLat(la);
long1x:=GetLon(la);
if (lat1x=lat1) and (long1x=long1) then
begin
ret1:=postcode1;
break;
end;
end;

end;
//-------------------------------------------------
except
on e:exception do begin end;
end;
end;
end;
if ret1='NotF' then
begin
dist:=dist+0.5;
goto loop1;
end;
result:=ret1;
end;

end.
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 12-16-2002
Junior Member
White Belt
 
Join Date: Nov 2002
Posts: 10
Yıldıray,

Thanks very much for you help. I copied your code but I can't get it to work: I get an access violation on frs:=map11.FindAddressResults(street1,city1,'','', '',nl);

I haven't been able to get the activeX control in Delphi as you described in MP2K magazine, so I added to the var section of the program the following:
MyInterface : _Application;
map11 : _Map;

And to the beginning of FormCreate the following:
MyInterface:=CoApplication.Create;
map11:=MyInterface.ActiveMap;

Can these alterations cause the problem and how can I get the activeX control of MP in Delphi?

Again, thanks very much for your help. This is a really big problem for me.

Pascal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 12-23-2002
Junior Member
White Belt
 
Join Date: Nov 2002
Posts: 10
it DOES work!

Mmm, I reinstalled Delphi and now this solution does work. Guess I did something wrong with the installation of the ActiveX components.

Thanks a lot!

By the way, I have contacted Microsoft about this issue and they admit tihs is a bug. They don't think they will fix it before the next release of MapPoint.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 01-03-2003
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Unfortunately, this solution does not work in all parts of the Netherlands, I just noticed. This is a really nasty problem.
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

Tags
click, street


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
Where did I click on that line? Jumbly MapPoint 2006/2009 Discussion 3 12-08-2004 03:53 AM
Long/Lat from click. Milo MapPoint 2006/2009 Discussion 7 10-29-2004 07:32 AM
Double Click on a Pushpin Anonymous MapPoint 2006/2009 Discussion 4 02-28-2004 06:26 PM
How to add click event for VB.Net ? Anonymous MapPoint 2006/2009 Discussion 2 12-31-2003 12:15 AM
Double Click on map Anonymous MapPoint 2006/2009 Discussion 0 08-08-2003 06:42 PM


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


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC2
MP2K Magazine
Visitor Map

Corfu Holiday
Why not enjoy the option of a Corfu holiday through UlookUbook? Check out the online offers...



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