Mappoint Methods question

Mappoint Methods question

Postby George » Fri Aug 07, 2009 2:06 am

Forum,

I am trying to use ActiveX with Mappoint. I found the following code in this forum
FUNCTION MapPointTest()
   local hToolBar, hStandard, oMapPoint, nDist
   oActiveX = TActiveX():New( oWnd, "MapPoint.Control.16" )
   oWnd:oClient = oActiveX // To fill the entire window surface

   oActiveX:Do( "Newmap", 1 )
   hToolBar = oActiveX:;GetProp( "Toolbars" )
   hStandard = OleGetProperty( hToolBar, "Item", "Standard" )
   OleSetProperty( hStandard, "Visible", .T. )
    oActiveX:GetProp( "Toolbars" )

   // The following code generate error
   oActiveX:Distance('205 Broadway, Lawrence, MA', '77 Centre Street, Boston, MA' )[/code] 
Error description: Error BASE/1004 Message not found: TACTIVEX:DISTANCE

From Mappoint Method help (Microsoft Developer Network)
Code: Select all  Expand view
Applies to
Objects:   Map

Syntax
object.Distance(StartLocation, EndLocation)

Parameters
Part Description
object Required. An expression that returns a Map object.
StartLocation Required Location object. The start point of the distance to be measured.
EndLocation Required Location object. The end point of the distance to be measured.
I am using FWH 9.06 + xHarbour Sep 08 and a Mappoint trial version.

Any clue why ActiveX does not recognize the Distance method?

Regards,

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: Mappoint Methods question

Postby James Bott » Fri Aug 07, 2009 6:25 am

George,

I have no experience with MapPoint but this:

"StartLocation Required Location object."

Might be indicating that the startLocation needs to be an object not a string. It is hard to tell from the description given.

Is there a method to return a location object from a string?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Mappoint Methods question

Postby lailton.webmaster » Fri Aug 07, 2009 7:36 am

oActiveX:Do("Distance","205 Broadway, Lawrence, MA", "77 Centre Street, Boston, MA")

try it.

:lol:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Mappoint Methods question

Postby George » Fri Aug 07, 2009 1:11 pm

James, Laiton
Thanks for responding my question.

Laiton,
If I use oActiveX:Do("Distance","205 Broadway, Lawrence, MA", "77 Centre Street, Boston, MA")
I get the same error message as before.

James,
This this the info from Microsoft developer network:
//------------------------------------------------------------------------------------------
Distance method
Returns the distance between two locations, in GeoUnits (miles or kilometers) as Double.

Applies to
Objects: Map

Syntax
object.Distance(StartLocation, EndLocation)

Parameters
Part Description
object Required. An expression that returns a Map object.
StartLocation Required Location object. The start point of the distance to be measured.
EndLocation Required Location object. The end point of the distance to be measured.

Remarks
To return the distance to a location, route, or route segment from another location, use the DistanceTo method on a Directions collection or Direction or Location object.

To return or set GeoUnits, use the Units property of an Application or MappointControl object.

Example
[Microsoft Visual Basic 6.0]
Sub ShowDistanceNYToLA()
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLocNY As MapPoint.Location
Dim objLocLA As MapPoint.Location
Dim objCenter As MapPoint.Location
Dim objTextbox As MapPoint.Shape
'Set up application and create Location objects
Let objApp.Visible = True
Let objApp.UserControl = True
Set objMap = objApp.ActiveMap
Set objLocNY = objMap.FindResults("New York, NY").Item(1)
Set objLocLA = objMap.FindResults("Los Angeles, CA").Item(1)
'Find the point on the screen midway between the two
X1% = objMap.LocationToX(objLocNY)
Y1% = objMap.LocationToY(objLocNY)
X2% = objMap.LocationToX(objLocLA)
Y2% = objMap.LocationToY(objLocLA)
x% = (X1% + X2%) / 2
y% = (Y1% + Y2%) / 2
Set objCenter = objMap.XYToLocation(x%, y%)
'Show the distance
objMap.Shapes.AddLine objLocNY, objLocLA
Set objTextbox = objMap.Shapes.AddTextbox(objCenter, 200, 50)
Distance# = objMap.Distance(objLocNY, objLocLA)
Let objTextbox.Text = "Distance, New York to Los Angeles: " & Distance#
End Sub

[C#]
void ShowDistanceNYtoLA()
{
ApplicationClass objApp = null;
MapPoint.Map objMap;
MapPoint.Shape objTextBox;
String Place1 = "New York, NY";
String Place2 = "Los Angeles,CA";
double Distance;

//Create an application class instance
objApp = new ApplicationClass();

//Set up application
objApp.Visible = true;
objApp.UserControl = true;
objMap = objApp.ActiveMap;
object Item = 1;

MapPoint.FindResults obNY = objMap.FindResults(Place1);
MapPoint.FindResults obLA= objMap.FindResults(Place2);
MapPoint.Location objNY = obNY.get_Item(ref Item) as MapPoint.Location;
MapPoint.Location objLA = obLA.get_Item(ref Item) as MapPoint.Location;
objNY.GoTo();
objLA.GoTo();

MapPoint.SelectedArea sa = objMap.SelectedArea;
MapPoint.Location objCenter = objMap.XYToLocation(sa.Left + sa.Width, sa.Top + sa.Height);

objMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeOval, objLA, 50, 30);
objMap.Shapes.AddLine(objNY.Location, objLA.Location);
Distance = objMap.Distance(objNY, objLA);

objTextBox = objMap.Shapes.AddTextbox(objCenter, 100, 50);
objTextBox.Text = ("Distance, NY to LA: " + Distance);
objMap.Altitude = 350;
}
Note This sample code is specifically for use in MapPoint North America; it is for illustration purposes only
//------------------------------------------------------------------------------------------

Do you know how "translate" this code to xHarbour + FWH?
Can you give me some tips?


Thanks,


George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: Mappoint Methods question

Postby lailton.webmaster » Fri Aug 07, 2009 1:22 pm

George

where i do download this SDK ?

send link i make download and make translation it for you.

gracias :D
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Mappoint Methods question

Postby James Bott » Fri Aug 07, 2009 2:55 pm

George,

As I said the locations have to be objects. Try this:

oStartLocation:= oActiveX:FindResults("205 Broadway, Lawrence, MA"):Item(1)
oEndLocation:= oActiveX:FindResults("77 Centre Street, Boston, MA"):Item(1)

msgInfo( oActiveX:Distance( oStartLocation, oEndLocation ), "Distance" )

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Mappoint Methods question

Postby George » Sat Aug 08, 2009 3:06 pm

James,
Your suggestion seem logic but using the below code I get run mappoint but also the same error message: Error description: Error BASE/1004 Message not found: TACTIVEX:FINDRESULTS

local hToolBar, hStandard, oMapPoint, nDist
oActiveX = TActiveX():New( oWnd, "MapPoint.Control.16" )
oWnd:oClient = oActiveX // To fill the entire window surface

oActiveX:Do( "Newmap", 1 )
hToolBar = oActiveX:GetProp( "Toolbars" )
hStandard = OleGetProperty( hToolBar, "Item", "Standard" )
OleSetProperty( hStandard, "Visible", .T. )
oActiveX:GetProp( "Toolbars" )

oStartLocation:= oActiveX:FindResults("205 Broadway, Lawrence, MA"):Item(1)
oEndLocation:= oActiveX:FindResults("77 Centre Street, Boston, MA"):Item(1)

msgInfo( oActiveX:Distance( oStartLocation, oEndLocation ), "Distance" )


Laiton,
This is the link: http://msdn.microsoft.com/en-us/library/aa562314.aspx
You can download a Mappoint trial version from here: http://www.microsoft.com/mappoint/en-us ... t_download

Regards,

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: Mappoint Methods question

Postby James Bott » Sun Aug 09, 2009 4:12 pm

George,

Try this:

local hToolBar, hStandard, oMapPoint, nDist, oMap
oActiveX = TActiveX():New( oWnd, "MapPoint.Control.16" )
oWnd:oClient = oActiveX // To fill the entire window surface

oActiveX:Do( "Newmap", 1 )
hToolBar = oActiveX:GetProp( "Toolbars" )
hStandard = OleGetProperty( hToolBar, "Item", "Standard" )
OleSetProperty( hStandard, "Visible", .T. )
oActiveX:GetProp( "Toolbars" )

oMap := oActiveX:ActiveMap
oStartLocation:= oMap:FindResults("205 Broadway, Lawrence, MA"):Item(1)
oEndLocation:= oMap:FindResults("77 Centre Street, Boston, MA"):Item(1)

msgInfo( oActiveX:Distance( oStartLocation, oEndLocation ), "Distance" )


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Mappoint Methods question

Postby George » Mon Aug 10, 2009 2:18 pm

Hi James,
Mappoint program open OK but now we get the error mesage in oMap := oActiveX:ActiveMap

Error description: Error BASE/1004 Message not found: TACTIVEX:ACTIVEMAP

Regards,

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: Mappoint Methods question

Postby lailton.webmaster » Tue Aug 11, 2009 9:18 am

Try it.

Code: Select all  Expand view
oMap := oActiveX:Do("ActiveMap")

 oStartLocation:= oMap:FindResults("205 Broadway, Lawrence, MA"):Item(1)
 oEndLocation:= oMap:FindResults("77 Centre Street, Boston, MA"):Item(1)
 
 oActiveX:Do("Distance", oStartLocation, oEndLocation )

 X1 := oMap:LocationToX(oStartLocation)
 Y1 := oMap:LocationToY(oStartLocation)
 X2 := oMap:LocationToX(oEndLocation)
 Y2 := oMap:LocationToY(oEndLocation)
 x  := (X1 + X2) / 2
 y  := (Y1 + Y2) / 2
objCenter := oMap:XYToLocation(x, y)

oMap:Shapes:AddLine( oStartLocation, oEndLocation)
objTextbox := oMap:Shapes:AddTextbox(objCenter, 200, 50)
Distance := oMap:Distance(objLocNY, objLocLA)
msginfo("Distance, x to Y é : " + Distance )
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Mappoint Methods question

Postby George » Tue Aug 11, 2009 3:23 pm

Lailton
I tried different approach but there are not working.
I am getting the same message
Error description: Error BASE/1004 Message not found: TACTIVEX:ACTIVEMAP

I think is more easy to get the distance by using google map API.

Regards,


George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: Mappoint Methods question

Postby lailton.webmaster » Tue Aug 11, 2009 3:30 pm

oMap := oActiveX:Do("ActiveMap")
ou
oMap := oActiveX:GetProp("ActiveMap")

what is your version of fwh ?
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Mappoint Methods question

Postby George » Tue Aug 11, 2009 4:26 pm

I am getting the following message:
Error description: Error BASE/1004 Class: 'NUMERIC' has no exported method: FINDRESULTS
Args:
[ 1] = N 0
[ 2] = C 205 Broadway, Lawrence, MA



I am using
FWH 9.06 + xHarbour Builder pro (Sep 08). Xharbou Pro uses PellesC not Borland.

Regards,

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Re: Mappoint Methods question

Postby James Bott » Tue Aug 11, 2009 6:29 pm

Check the valtype() of oMap right after it is created. From the error method it looks like it is a number.

msgInfo( valtype( oMap ) )

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Mappoint Methods question

Postby George » Tue Aug 11, 2009 7:13 pm

By using the following code:
local hToolBar, hStandard, oMapPoint, nDist, oMap
oActiveX = TActiveX():New( oWnd, "MapPoint.Control.16" )
oWnd:oClient = oActiveX // To fill the entire window surface

oMap := oActiveX:Do( "Newmap", 1 )
msginfo(valtype(oMap)) // NUMERIC
msginfo(oMap) //1706844
// If I try with oMap := oActiveX:Do("ActiveMap") or oMap := oActiveX:GetProp("ActiveMap")
// I get oMap = 0 and error message before open MapPoint

hToolBar = oActiveX:GetProp( "Toolbars" )
hStandard = OleGetProperty( hToolBar, "Item", "Standard" )
OleSetProperty( hStandard, "Visible", .T. )
oActiveX:GetProp( "Toolbars" )

// Here is the problem
oStartLocation:= oMap:FindResults("205 Broadway, Lawrence, MA"):Item(1)
oEndLocation:= oMap:FindResults("77 Centre Street, Boston, MA"):Item(1)

I get open MapPoint; see image:
[url]Image[/url]

But I get the error whe trying to use FindResults method.

I figure out that I am using FWH 8.05 + xHarbour Builder Pro Sep 08.
I will try with a most recent FWH version.

George
George
 
Posts: 724
Joined: Tue Oct 18, 2005 6:49 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 19 guests