Page 1 of 2

Message for Randal Ferguson

PostPosted: Wed Aug 16, 2006 7:54 am
by Peterg
Hi Randal

I have beed told that you have done some work with FW and GIS mapping systems. Can you share what and how you achieved this as I want to be able to link mapping into my applications

Regards
Peter Gardner

PostPosted: Wed Aug 16, 2006 3:47 pm
by Randal
Peter Gardner,

I have worked some with Microsoft MapPoint. Is this what you are going to use? What exactly are you wanting to do?

Regards,
Randal Ferguson

PostPosted: Wed Aug 16, 2006 4:08 pm
by Peterg
Yes I think that I will use mappoint. Basically what I want to do is invoke the mapping system and pass locations of containers so that they can see these positioned on the map. Ideally it would be good if they could then plot a route between locations

Regards
Peter

PostPosted: Thu Aug 17, 2006 12:35 am
by Silvio
Dear Randal,
I'm interested for YOur Work...
Can U send a simple sample to invoke microsoft Mappoint to search a position to a map and print it ..?

Regards,

PostPosted: Thu Aug 17, 2006 8:03 pm
by Randal
Do you want to use it via ole or activex? I needed to use via activex but could not get events to work so I put it on the back burner for now.

I could give you a little sample code for using it via ole if that would help.

Regards,
Randal Ferguson

PostPosted: Thu Aug 17, 2006 11:08 pm
by Silvio
thanks I can try via ole ...

PostPosted: Fri Aug 18, 2006 7:57 am
by Peterg
Randal

Yes please can I have the sample as well

Peter

PostPosted: Fri Aug 18, 2006 8:56 am
by Antonio Linares
Please upload it to www.hyperupload.com and copy the download url here so others can have it too, thanks.

PostPosted: Fri Aug 18, 2006 1:17 pm
by Randal
Give me a little time to clean up the code and I'll post some samples.

Regards,
Randal Ferguson

PostPosted: Fri Aug 18, 2006 1:30 pm
by Silvio
thanks very thanks

PostPosted: Tue Aug 22, 2006 1:47 pm
by Randal
Here is some sample code to get you started. I'm sorry it's kind of a hack job but I'd be happy to answer any questions if I can. This code works with FWH/xHarbour. You can get info on all the methods and data using the link below.

http://msdn.microsoft.com/library/defau ... OMOMap.asp


#INCLUDE "fivewin.CH"
#INCLUDE "commands.ch"

#define CRLF Chr( 13 ) + Chr( 10 )

#DEFINE geoDelimiterComma 44
#DEFINE geoDelimiterDefault 0
#DEFINE geoDelimiterSemicolon 59
#DEFINE geoDelimiterTab 9

#DEFINE geoDisplayBalloon 2
#DEFINE geoDisplayName 1
#DEFINE geoDisplayNone 0

STATIC oWndMap
STATIC oMapPoint

/*
This version calls mappoint via ole and actually opens an instance of the mappoint application
*/

PROCEDURE MapPoint()

LOCAL oMapDS
LOCAL oRecordSet
LOCAL oRoute
LOCAL oWaypoints
LOCAL aFields := {}, i
LOCAL hWnd

TRY
oMapPoint := GetActiveObject( "MapPoint.Application" )
CATCH
TRY
oMapPoint := CreateObject( "MapPoint.Application" )
CATCH
Msginfo( "Map Point not avialable." )
// For some reason, using ole2TxtError causes gpf!
* Msginfo( "ERROR! MapPoint not avialable. [" + Ole2TxtError()+ "]" )
RETURN NIL
END
END

oMapPoint:NewMap(1)
oMapPoint:Toolbars:Item("Standard"):Visible := .T.
oMapPoint:Toolbars:Item("Navigation"):Visible := .T.
oMapPoint:Toolbars:Item("Drawing"):Visible := .T.
oMapPoint:Toolbars:Item("Location and Scale"):Visible := .T.
oMapPoint:PaneState := 1 // Turn on legend for route planer

// These two only valid for mappoint application object, not a control object
oMapPoint:Visible := .T.
oMapPoint:UserControl := 1 // Give control to user

oWndMap:oClient = oMapPoint // To fill the entire window surface

// Import data - automatically adds a dataset object to the datasets collection
// There doesn't seem to be a way to create an empty dataset
// Importing seems to be the fastest way. Using FindAddressResults is way to slow...
// You can use a .csv or .Txt file. Have to specify a delimiter if using .txt
* oMapPoint:ActiveMap:DataSets:ImportData("merge.csv")
oMapPoint:ActiveMap:DataSets:ImportData("merge.txt", , ,geoDelimiterComma) // Have to specify geoDelimiterComma

* msginfo( oMapPoint:ActiveMap:DataSets:Count, "DataSets Count" )
* msginfo( oMapPoint:ActiveMap:Path, "DataSets Path" )

// Use the Item property of the DataSets object to access each DataSet objects. Can use index or name as subscript

// Set the pushpin symbol
oMapPoint:ActiveMap:DataSets:Item(1):Symbol := 1
* oMapPoint:ActiveMap:DataSets:Item(2):Symbol := 2

// Set the name of the DataSet
oMapPoint:ActiveMap:DataSets:Item(1):Name := "1"
* oMapPoint:ActiveMap:DataSets:Item(2):Name := "Route 2"

// Choose which fields to display in balloon. Defaults to name and address. Below uses all fields passing the fields collection object
FOR i := 1 TO oMapPoint:ActiveMap:DataSets:Item(1):Fields:Count
aadd( aFields,oMapPoint:ActiveMap:DataSets:Item(1):Fields[i] )
NEXT
oMapPoint:ActiveMap:DataSets:Item(1):SetFieldsVisibleInBalloon( aFields )

// Zoom to the datasets on map
oMapPoint:ActiveMap:DataSets:ZoomTo()

// Display the balloon for the first address
oMapPoint:ActiveMap:DataSets:Item(1):QueryAllRecords:Pushpin:BalloonState = geoDisplayBalloon

// Return RecordSet for DataSet
oRecordSet := oMapPoint:ActiveMap:DataSets:Item(1):QueryAllRecords

// Initialize counter subscript
i := 1
// Add WayPoints for each record in the RecordSet
DO WHILE !oRecordSet:EOF
// Add WayPoint for each location in the recordset
oMapPoint:ActiveMap:ActiveRoute:WayPoints:Add(oRecordSet:Location)
// Set the PreferredArrival time
* oMapPoint:ActiveMap:ActiveRoute:WayPoints:Item(1):PreferredArrival := oRecordSet:Fields:Item(8):Value
// Set start time for route. Although I can't read datetime data type the value can be set.
// Have to set here because there is no way to simply move to the last record in the recordset.
// The recordset is in the opposite order that the records are imported.
* IF !empty( oRecordSet:Fields:Item(8):Value )
* MSGINFO( MapTime( oRecordSet:Fields:Item(9):Value ), i )
* oMapPoint:ActiveMap:ActiveRoute:DriverProfile:StartTime := MapTime( oRecordSet:Fields:Item(9):Value )
* ENDIF
oRecordSet:MoveNext()
i++
ENDDO

// Return a Waypoints collection object
oWaypoints := oMapPoint:ActiveMap:ActiveRoute:Waypoints
// Loop thru WayPoints collection setting StopTime for each stop
* FOR i := 1 TO oWaypoints:Count
* oWaypoints:Item(i):StopTime := .125 // 3 hrs 3/24 = .125
* NEXT

// Sample code adding a pushpin using FindResults method
// Add a new pushpin set
/* oMapPoint:ActiveMap:DataSets:AddPushpinSet("NewSet 1")
oMapPoint:ActiveMap:DataSets:AddPushpinSet("NewSet 2")
// Creates a FindResults Collection object with one location object
do while !eof()
oLoc := oMapPoint:ActiveMap:FindAddressResults( alltrim(Customer->addr1), alltrim(Customer->city), alltrim(Customer->state), alltrim(Customer->zip), )
oMapPoint:ActiveMap:AddPushpin( oLoc:Item(1), alltrim( Customer->name) )
dbskip()
enddo
oMapPoint:ActiveMap:DataSets:ZoomTo()
oLoc := oMapPoint:ActiveMap:FindAddressResults("123 main st", "houston", "TX", "77074", )
oMapPoint:ActiveMap:AddPushpin( oLoc:Item(1), "John Smith" ) */

RETURN NIL

PostPosted: Tue Aug 22, 2006 2:44 pm
by Peterg
Thankls Randal will give it a try


Peter

PostPosted: Tue Aug 22, 2006 4:51 pm
by Silvio
randal
this sample could run with Ocx microsoft map point ?
I found it at http://msdn.microsoft.com/library/defau ... pPoint.asp

Regards

PostPosted: Tue Aug 22, 2006 8:12 pm
by Randal
Silvio wrote:randal
this sample could run with Ocx microsoft map point ?
I found it at http://msdn.microsoft.com/library/defau ... pPoint.asp

Regards


Mappoint OCX allows you to turn on the Standard, Navigation, Drawing, Location and Scale toolbars. However I could not get FWH to respond to any mouse clicks on any of the options available on the toolbars.

You'll notice that Excel, Word, and other OCX's expose a default toolbar you can click on and the activex handles the events. I haven't been able to make this work with Mappoint.

Regards,
Randal Ferguson

PostPosted: Mon Jan 29, 2007 1:23 pm
by Silvio
Randal
where i can download Mappoint control activex ?