Message for Randal Ferguson
Message for Randal Ferguson
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Please upload it to www.hyperupload.com and copy the download url here so others can have it too, thanks.
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 )
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
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 )
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
randal
this sample could run with Ocx microsoft map point ?
I found it at http://msdn.microsoft.com/library/defau ... pPoint.asp
Regards
this sample could run with Ocx microsoft map point ?
I found it at http://msdn.microsoft.com/library/defau ... pPoint.asp
Regards
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
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.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
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