Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Lat/Long in MapPoint and Delphi 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. |
| |||
| 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 |
| |||
| 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! |
| |||
| 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..
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| delphi, lat or long, mappoint |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |
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!