MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Lat/Long in MapPoint and Delphi

This is a discussion on Lat/Long in MapPoint and Delphi within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, i am using the MapPoint ActiveX control in Delphi 7 and i just cannot get the Lat/Long of the ...


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

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



Click here to register

Reply

 

LinkBack (11) Thread Tools Display Modes
  11 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 04-26-2007
Junior Member
White Belt
 
Join Date: Apr 2007
Posts: 5
Lat/Long in MapPoint and Delphi

Hi,

i am using the MapPoint ActiveX control in Delphi 7 and i just cannot get the Lat/Long of the mouse position on map...

I tried (succesfully) to get the Lat/Long of a specific Location object, but i need something to convert the graphic XY coordinates of the mouse to Lat/Long coordinates. I also tried the function XYToLocation(X,Y: integer), but that doesn't seem to work because it never returns a valid location...

I want the lat/long coordinates so i can programmatically add a pushpin where the user clicks the map. Maybe there is an easier solution for this? Any idea would be helpful!

Marius.
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-26-2007
Junior Member
White Belt
 
Join Date: Jul 2006
Posts: 5
Re: Lat/Long in MapPoint and Delphi

Global var
MouseX : Real ;
MouseY : Real ;







type
TLatLong = record
Lat : Double;
Long: Double;
End;


Function GetLatLong(M: TMapPointControl; Loc: Location): TLatLong;
var
LocNorthPole : Location;
LocSantaCruz : Location;
DblHalfEarth : Double;
DblQuarterEarth : Double;
DblLat : Double;
DblLon : Double;
L, D : Double;
Begin
LocNorthPole := M.ActiveMap.GetLocation(90, 0, 0);
LocSantaCruz := M.ActiveMap.GetLocation(0, -90 , 0);
DblHalfEarth := M.ActiveMap.Distance(locNorthPole, M.ActiveMap.GetLocation(-90, 0, 0));
DblQuarterEarth := dblHalfEarth / 2;
DblLat := 90 - 180 * M.ActiveMap.Distance(LocNorthPole, loc) / DblHalfEarth;
D := M.ActiveMap.Distance(M.ActiveMap.GetLocation(DblLa t, 0, 0), Loc);
L := (DblLat / 180) * Pi;
DblLon := 180 * Arccos((Cos((d * 2 * Pi) / (2 * DblHalfEarth)) - Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / Pi;
If M.ActiveMap.Distance(LocSantaCruz, Loc) < DblQuarterEarth Then DblLon := - DblLon;
Result.Long := DblLon ;
Result.Lat := DblLat ;
End;






procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Var
MyLococation: Location;
begin

MyLococation := Map.ActiveMap.XYToLocation(X, Y);
MouseX := GetLatLong(Map, Loc).Lat ;
MouseY := GetLatLong(Map, Loc).Long ;


This should fill MouseX and mouseY with the lat and long of the mouse pointer.

This could be used in form mousedown or form mousemove, This works ok for me, please let me know if you need more details

Nigel
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-26-2007
Junior Member
White Belt
 
Join Date: Apr 2007
Posts: 5
Re: Lat/Long in MapPoint and Delphi

Yes, thanks very much... this works great. Actually, i used the same function, but it seems that i passed it on the simple Map component and not ActiveMap. By doing so, i never go a valid location on map (don't know why).

Nevertheless, thanks a lot Nigel!
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-26-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,105
Re: Lat/Long in MapPoint and Delphi

the activeX control in delphi 7 ? I was pretty sure it was not working ... unsupported interface or something... So I used the object interface..
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 05-02-2007
Junior Member
White Belt
 
Join Date: Apr 2007
Posts: 5
Re: Lat/Long in MapPoint and Delphi

Well, that is an old problem that can be solved by just doing some modifications in the MapPoint_TLB file... After that you have working components!

Marius.
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
delphi, lat or long, mappoint


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/lat-long-mappoint-delphi-5849.html

Posted By For Type Date
A More Compact Method for Obtaining Lat/Long - MapPoint Articles - MP2K Magazine This thread Refback 05-14-2007 03:04 AM
An API to Control MapPoint 2006 GPS Features - Part I of II - MapPoint Articles - MP2K Magazine This thread Refback 05-10-2007 07:04 PM
Wisconsin Map and Map of Wisconsin - MapPoint State Map Gallery - MP2K Magazine This thread Refback 05-10-2007 01:17 PM
Extending the MapPoint ActiveX Control - Pt. I - MapPoint Articles - MP2K Magazine This thread Refback 05-09-2007 12:06 PM
Working With Excel and MapPoint - MP2K Magazine This thread Refback 05-08-2007 12:34 AM
MapPoint Help - MP2K Magazine This thread Refback 05-06-2007 12:37 AM
MapPoint Articles - MP2K Magazine This thread Refback 05-03-2007 09:36 AM
Creating Geocoding Exceptions for MapPoint Web Service Applications - MapPoint Articles - MP2K Magazine This thread Refback 04-30-2007 08:35 PM
Microsoft MapPoint 2006 - MP2K Magazine This thread Refback 04-30-2007 12:18 PM
Caravel - Next Generation Platform for Mobile Mapping - MapPoint News - MP2K Magazine This thread Refback 04-28-2007 05:32 PM
Using MapPoint In Delphi - MapPoint Articles - MP2K Magazine This thread Refback 04-28-2007 05:03 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
Using MapPoint In Delphi Anonymous MP2K Magazine Articles 8 12-05-2005 09:51 AM
MapPoint 2004 and Delphi 5 Anonymous MapPoint 2006/2009 Discussion 6 01-20-2005 06:34 AM
Mappoint addin with Delphi 6 jeanluc MapPoint 2006/2009 Discussion 2 09-15-2003 02:03 PM
MapPoint.Application in Delphi joesebi MapPoint 2006/2009 Discussion 1 07-11-2003 05:16 AM
Mappoint With Delphi 5 stuarth MapPoint 2006/2009 Discussion 1 04-08-2003 10:21 AM


All times are GMT -5. The time now is 10:11 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

Cheap Ski Holidays Austria
For the best cheap ski holidays, Austria has a charm all of its own. Check out the unspoilt, picturesque villages with superb ski resorts of all types.

Best Travel Agent
Book your Travel with the UK's best Travel Agent - as named at the Guardian Unlimited Travel awards.

Flights to Canada
Looking for cheap flights to Canada? dealchecker.co.uk helps you compare prices from all major scheduled and charter airlines.

Antigua Holidays
We have the most popular Antigua holidays at highly competitive prices at The Holiday Place. Book a break in sunny Antigua today.

Cheap Balearics Holidays
Cheap Balearics holidays are available if you know when to book and who to book with. The Balearics have many fascinating places to visit all year round. The partying never stops.

All inclusive holiday
Travel.co.uk is a travel comparison service which makes it easy to search and find your all inclusive holiday.

Florida Holidays
Take a sunny holiday break! Find info on Florida holidays 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 52