PWB 505: Using MS MapPoint in PowerBuilder - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

PWB 505: Using MS MapPoint in PowerBuilder

Description:

Calculation of distance or driving time. Getting directions. Preparing The Map ... Get Directions. Create and calculate route. Same as for getting distance and ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 27
Provided by: downloa4
Category:

less

Transcript and Presenter's Notes

Title: PWB 505: Using MS MapPoint in PowerBuilder


1
PWB 505 Using MS MapPoint in PowerBuilder
Arthur Hefti CEO arthur_at_catsoft.ch 17. August 2004
2
Content Overview
  • Speaker introduction
  • Why GIS data
  • MS MapPoint control in PowerBuilder
  • OLE automation with MS MapPoint
  • Presentation of a service application

3
Speaker Introduction
  • Arthur Hefti
  • PowerBuilder developer since 1993
  • CPD Professional, CP Instructor
  • President Swiss PowerBuilder User Group for 5
    years
  • CEO of CATsoft Development GmbH, Zurich,
    Switzerland
  • Custom made software development and consulting
  • Client / Server and Web
  • Web http//www.catsoft.net or http//www.catsoft.
    ch
  • Email arthur_at_catsoft.ch

4
Why GIS Data
  • Planning a route
  • Service technician
  • Sales person
  • Tracking position
  • Delivery of goods
  • Driving instructions
  • Detailed directions

5
MS MapPoint Control
6
Important Objects
  • MapPoint control
  • Map object
  • Pushpins
  • Route
  • Directions
  • WayPoints
  • DataSet
  • FindResults collection
  • Location object

7
MapPoint Control
  • Window painter ? Insert Control ? OLE ...

8
Loading Map Data
  • Load the map into the control
  • ioo_Map ole_Map.Object.NewMap( 2 ) // 1
    North America, 2 Europe
  • Unload at the end
  • ole_Map.Object.CloseMap()

9
Finding Locations
  • Find the location
  • Returns a collection of locations including
    quality of the result
  • loo_Found ioo_Map.FindAddressResults( ltStreetgt,
    ltCitygt, ltOthercitygt,
  • ltRegiongt, ltZipgt, ltCountrygt )
  • IF loo_Found.ResultsQuality 1
    /geoFindResultGood/ THEN
  • loo_Location loo_Found.Item(1)
  • ELSE // Let the user manually select one location
  • .....
  • Add pushpins
  • loo_Pin ioo_Map.AddPushpin( loo_Location,
    Pushpin 1 )

10
Working With DataSets And Pushpins
  • Pushpins are added to the My Pushpins set
  • loo_Pin ioo_Map.AddPushpin( loo_Location,
    Pushpin 1 )
  • Create your own set
  • ioo_Tour ioo_Map.DataSets.AddPushPinSet(
    "MyTour" )
  • Move pushpins between DataSets
  • loo_Pin.MoveTo( ioo_Tour )
  • DataSets allow to access groups of data
  • ioo_Tour.FieldNamesVisibleInBalloon TRUE

11
The Route
  • Get route object and reset it
  • ioo_Route ioo_Map.ActiveRoute
  • loo_Route.Clear()
  • Get waypoint object and add pushpins
  • loo_WayPoints loo_Route.WayPoints
  • loo_WayPoints.Add( loo_Pin1 )
  • loo_WayPoints.Add( loo_Pin2 )
  • Draw the route
  • Ioo_Route.Calculate()

12
User Interaction With The Map
  • Default behavior
  • Allow or overwrite
  • Events
  • Notification of Map Control
  • Methods
  • Managing the Map Control

13
Default Behavior
  • Right mouse button menu
  • Zoom
  • Export to Excel
  • Route creation
  • Show Pushpin Information
  • Left mouse button
  • Moving of Pushpins
  • Scrolling the map
  • Mouse wheel
  • Zoom

14
Events
  • Various events for interaction and state changes
  • Most important events for user interaction
  • beforeclick Display some information about
    clicked object(s)
  • beforedblclick Execute some action
  • mousedown Save mouse pointer position
  • Other events
  • afterredraw
  • routeaftercalculate

15
Methods
  • Opening map data
  • NewMap()
  • Loading and saving maps
  • OpenMap()
  • SaveMap()
  • Closing
  • CloseMap()

16
OLE Automation With MapPoint
  • Used if no visual part is needed
  • Calculation of distance or driving time
  • Getting directions

17
Preparing The Map
  • Creating a new instance
  • OleObject ioo_App, ioo_Map
  • ioo_App CREATE OleObject
  • ioo_App.ConnectToNewObject( "MapPoint.Application"
    )
  • Get active map
  • ioo_Map ioo_App.ActiveMap

18
Calculate Distance And Driving Time
  • Initialize route
  • Create route
  • Calculate the route
  • Return distance

19
Initialize Route
  • Initialize route
  • loo_Route ioo_Map.ActiveRoute
  • loo_Route.Clear()
  • loo_WayPoints loo_Route.WayPoints

20
Create Route
  • Find the location
  • Returns a collection of locations including
    quality of the result
  • loo_Found ioo_Map.FindAddressResults(
    ls_Street, ls_City, "", ls_Region,
  • ls_PostalCode, ll_CountryCode )
  • IF loo_Found.ResultsQuality 1
    /geoFindResultGood/ THEN
  • loo_Location loo_Found.Item(1)
  • ...
  • Add pushpins
  • loo_Pin ioo_Map.AddPushpin( loo_Location,
    "Item" String( li_Counter ) )
  • loo_WayPoints.Add( loo_Pin )

21
Calculate The Route
  • Calculate and catch a possible runtime error
  • TRY
  • loo_Route.Calculate()
  • CATCH (OLERuntimeError err)
  • MessageBox( Error, Calculating Route,
    StopSign! )
  • END TRY

22
Get Distance Or Driving Time
  • Create route
  • ll_Distance loo_Route.Distance
  • ll_DrivingTime Long( loo_Route.DrivingTime
    24 60 )

23
Get Directions
  • Create and calculate route
  • Same as for getting distance and driving time
  • Get all direction information
  • loo_Directions loo_Route.Directions
  • FOR li_Counter 1 TO loo_Directions.Count
  • loo_DirectionEntry looDirections.Item(
    li_Counter )
  • ls_Dir ls_Dir loo_DirectionEntry.Instruction
    Char(13) Char(10)
  • NEXT

24
Key Figures For Demo Application
  • Application is used in service company
  • 2200 places to visit by 35 technicans in peak
    month
  • 1200 places and 10 technicans planned at the same
    time
  • Used in different locations across Switzerland
  • Runing in LAN and on Citrix

25
Demo
26
Questions?
Write a Comment
User Comments (0)
About PowerShow.com