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 6 of 6

What happens when YOU click on a street?

This is a discussion on What happens when YOU click on a street? within the MapPoint Desktop 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. ...

  1. #1
    schuchhardp is offline 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

  2. #2
    yelmaci is offline Junior Member White Belt
    Join Date
    Dec 2002
    Posts
    7
    Hi pascal,

    See next post

  3. #3
    yelmaci is offline Junior Member White Belt
    Join Date
    Dec 2002
    Posts
    7
    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.

  4. #4
    schuchhardp is offline 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

  5. #5
    schuchhardp is offline 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.

  6. #6
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Unfortunately, this solution does not work in all parts of the Netherlands, I just noticed. This is a really nasty problem.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Where did I click on that line?
    By Jumbly in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 12-08-2004, 03:53 AM
  2. Long/Lat from click.
    By Milo in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 10-29-2004, 07:32 AM
  3. Double Click on a Pushpin
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 02-28-2004, 06:26 PM
  4. How to add click event for VB.Net ?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 12-31-2003, 12:15 AM
  5. Double Click on map
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 08-08-2003, 06:42 PM

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