INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

COM and Automation

Microsoft's Mappoint - Create a Datamap by craigsboyd
Posted: 12 Jul 03 (Edited 18 Feb 05)

Slighthaze = NULL

You will need at least the trial version of Mappoint 2001 or 2002 installed on your system in order to run this example.

This shows a simple example for automating Microsoft's Mappoint to show a datamap of sales totals by state.  The different colors represent sales within a particular range(see the legend to the left of the map).  These totals could have just as easily been broken out by ZIP code, county, city, or whatever.  The area shown could be as small as a part of town for instance showing one salesperson's territority and what the break outs were for it.  As you can see, this is kind of like an MS Chart on steroids.  This doesn't begin to scratch the surface of automating Mappoint from VFP, but it may give you a few new data reporting ideas.

Though the code looks like a lot, most of it is fluff...I wanted to show most of the Mappoint Constants and I set up a textfile to hold the sales totals and act as my data.

*CUT-N-PASTE the code below into a prg file and run it from within VFP

#DEFINE geoOneDay    1    
#DEFINE geoOneHour    0    
#DEFINE geoOneMinute    0    
#DEFINE geoColorSchemeDefault    -1    
#DEFINE geoDelimiterDefault    0    
#DEFINE geoDelimiterTab    9    
#DEFINE geoDelimiterComma    44    
#DEFINE geoDelimiterSpace    32    
#DEFINE geoCountryDefault    0    
#DEFINE geoCountryAlbania    6    
#DEFINE geoCountryArgentina    11    
#DEFINE geoCountryAustralia    12    
#DEFINE geoCountryAustria    14    
#DEFINE geoCountryBangladesh    23    
#DEFINE geoCountryBelarus    24    
#DEFINE geoCountryBelgium    21    
#DEFINE geoCountryBolivia    26    
#DEFINE geoCountryBrazil    32    
#DEFINE geoCountryBulgaria    35    
#DEFINE geoCountryCanada    39    
#DEFINE geoCountryChile    46    
#DEFINE geoCountryChina    45    
#DEFINE geoCountryColombia    51    
#DEFINE geoCountryCzechRep    75    
#DEFINE geoCountryDenmark    61    
#DEFINE geoCountryEcuador    66    
#DEFINE geoCountryEstonia    70    
#DEFINE geoCountryFinland    77    
#DEFINE geoCountryFrance    84    
#DEFINE geoCountryFrenchGuiana    76    
#DEFINE geoCountryGeorgia    88    
#DEFINE geoCountryGermany    94    
#DEFINE geoCountryGreece    98    
#DEFINE geoCountryHungary    109    
#DEFINE geoCountryIceland    110    
#DEFINE geoCountryIndia    113    
#DEFINE geoCountryIndonesia    111    
#DEFINE geoCountryIreland    68    
#DEFINE geoCountryItaly    118    
#DEFINE geoCountryJapan    122    
#DEFINE geoCountryLatvia    140    
#DEFINE geoCountryLithuania    141    
#DEFINE geoCountryLuxembourg    147    
#DEFINE geoCountryMalaysia    167    
#DEFINE geoCountryMexico    166    
#DEFINE geoCountryNetherlands    176    
#DEFINE geoCountryNorthKorea    131    
#DEFINE geoCountryNorway    177    
#DEFINE geoCountryParaguay    185    
#DEFINE geoCountryPeru    187    
#DEFINE geoCountryPoland    191    
#DEFINE geoCountryPortugal    193    
#DEFINE geoCountryRomania    200    
#DEFINE geoCountryRussia    203    
#DEFINE geoCountrySlovakia    143    
#DEFINE geoCountrySouthAfrica    209    
#DEFINE geoCountrySouthKorea    134    
#DEFINE geoCountrySpain    217    
#DEFINE geoCountrySuriname    181    
#DEFINE geoCountrySweden    221    
#DEFINE geoCountrySwitzerland    223    
#DEFINE geoCountryTurkey    235    
#DEFINE geoCountryUnitedKingdom    242    
#DEFINE geoCountryUkraine    241    
#DEFINE geoCountryUruguay    246    
#DEFINE geoCountryUnitedStates    244    
#DEFINE geoCountryVenezuela    249    
#DEFINE geoCountryMultiCountry    39070    
#DEFINE geoSegmentQuickest    0    
#DEFINE geoSegmentShortest    1    
#DEFINE geoSegmentPreferred    2    
#DEFINE geoMoveToTop    0    
#DEFINE geoMoveToBottom    1    
#DEFINE geoMoveUp    2    
#DEFINE geoMoveDown    3    
#DEFINE adEmpty    0    
#DEFINE adTinyInt    16    
#DEFINE adSmallInt    2    
#DEFINE adInteger    3    
#DEFINE adBigInt    20    
#DEFINE adUnsignedTinyInt    17    
#DEFINE adUnsignedSmallInt    18    
#DEFINE adUnsignedInt    19    
#DEFINE adUnsignedBigInt    21    
#DEFINE adSingle    4    
#DEFINE adDouble    5    
#DEFINE adCurrency    6    
#DEFINE adDecimal    14    
#DEFINE adNumeric    131    
#DEFINE adBoolean    11    
#DEFINE adError    10    
#DEFINE adUserDefined    132    
#DEFINE adVariant    12    
#DEFINE adIDispatch    9    
#DEFINE adIUnknown    13    
#DEFINE adGUID    72    
#DEFINE adDate    7    
#DEFINE adDBDate    133    
#DEFINE adDBTime    134    
#DEFINE adDBTimeStamp    135    
#DEFINE adBSTR    8    
#DEFINE adChar    129    
#DEFINE adVarChar    200    
#DEFINE adLongVarChar    201    
#DEFINE adWChar    130    
#DEFINE adVarWChar    202    
#DEFINE adLongVarWChar    203    
#DEFINE adBinary    128    
#DEFINE adVarBinary    204    
#DEFINE adLongVarBinary    205    
#DEFINE adChapter    136    
#DEFINE adFileTime    64    
#DEFINE adDBFileTime    137    
#DEFINE adPropVariant    138    
#DEFINE adVarNumeric    139    
#DEFINE geoFieldSkipped    0    && None
#DEFINE geoFieldName    1    && Name
#DEFINE geoFieldName2    2    && Name line 2
#DEFINE geoFieldAddress1    3    && Address line 1
#DEFINE geoFieldAddress2    4    && Address line 2
#DEFINE geoFieldAddress3    5    && Address line 3
#DEFINE geoFieldCity    6    && City
#DEFINE geoFieldRegion3    8    && Europe only:  ie Italian Provincia
#DEFINE geoFieldRegion2    9    && US County, French Departement
#DEFINE geoFieldRegion1    10    && ie US State, Canadian Province, Swiss Kanton
#DEFINE geoFieldPostal1    11    && Postal code 1 - most granular (i.e. ZIP, CAP)
#DEFINE geoFieldPostal2    12    && Postal code 2
#DEFINE geoFieldPostal3    13    && Postal code 3
#DEFINE geoFieldPostal4    14    && Postal code 4 - least granular
#DEFINE geoFieldCountry    15    && Country
#DEFINE geoFieldCensus1    16    && Census subdiv 1 - most granular (i.e. Census Tract)
#DEFINE geoFieldCensus2    17    && Census subdiv 2 - ie MSA
#DEFINE geoFieldOSGridRef    19    && British OS grid reference
#DEFINE geoFieldLatitude    20    && Latitude
#DEFINE geoFieldLongitude    21    && Longitude
#DEFINE geoFieldInformation    22    && Note field
#DEFINE geoFieldData    23    && User Defined - Data Mapping Field
#DEFINE geoDisplayNone    0    
#DEFINE geoDisplayName    1    
#DEFINE geoDisplayBalloon    2    
#DEFINE geoDataMapTypeDefault    -1    
#DEFINE geoDataMapTypeNone    0    
#DEFINE geoDataMapTypeShadedArea    1    
#DEFINE geoDataMapTypeSizedCircle    2    
#DEFINE geoDataMapTypeShadedCircle    3    
#DEFINE geoDataMapTypePushpin    4    
#DEFINE geoShowByZoomLevel    -2    
#DEFINE geoShowByDefault    -1    
#DEFINE geoShowByLatLong    5    
#DEFINE geoShowByOSGridRef    6    
#DEFINE geoShowByStreetAddress    7    
#DEFINE geoShowByCity    8    
#DEFINE geoShowByCensus1    9    
#DEFINE geoShowByCensus2    10    
#DEFINE geoShowByPostal1    12    
#DEFINE geoShowByPostal2    13    
#DEFINE geoShowByPostal3    14    
#DEFINE geoShowByPostal4    15    
#DEFINE geoShowByRegion3    16    
#DEFINE geoShowByRegion2    17    
#DEFINE geoShowByRegion1    18    
#DEFINE geoShowByCountry    19    
#DEFINE geoCombineByDefault    -1    
#DEFINE geoCombineByNone    0    
#DEFINE geoCombineByAdd    1    
#DEFINE geoCombineByAverage    2    
#DEFINE geoCombineByCount    3    
#DEFINE geoRangeTypeDefault    -1    
#DEFINE geoRangeTypeContinuous    1    
#DEFINE geoRangeTypeContinuousLog    2    
#DEFINE geoRangeTypeDiscreteEqualRanges    3    
#DEFINE geoRangeTypeEqualDataPoints    4    
#DEFINE geoRangeTypeDiscreteLogRanges    5    
#DEFINE geoRangeTypeUniqueValues    6    
#DEFINE geoRangeOrderDefault    -1    
#DEFINE geoRangeOrderLowToHigh    1    
#DEFINE geoRangeOrderHighToLow    2    
#DEFINE geoMapStyleRoad    0    
#DEFINE geoMapStyleRoadData    1    
#DEFINE geoMapStyleData    2    
#DEFINE geoMapStyleTerrain    3    
#DEFINE geoMapStylePolitical    4    
#DEFINE geoMapFontLargest    0    
#DEFINE geoMapFontLarger    1    
#DEFINE geoMapFontMedium    2    
#DEFINE geoMapFontSmaller    3    
#DEFINE geoMapFontSmallest    4    
#DEFINE geoFormatMap    0    
#DEFINE geoFormatTemplate    1    
#DEFINE geoFormatHTMLMap    2    
#DEFINE geoFormatHTMLDirections    3    
#DEFINE geoFormatHTMLMapAndDirections    4    
#DEFINE geoPrintMap    0    
#DEFINE geoPrintDirections    1    
#DEFINE geoPrintTurnByTurn    2    
#DEFINE geoPrintStripMaps    3    
#DEFINE geoPrintSelectedArea    4    
#DEFINE geoPrintHighlightedPlaces    5    
#DEFINE geoPrintQualityNormal    0    
#DEFINE geoPrintQualityDraft    1    
#DEFINE geoPrintQualityPresentation    2    
#DEFINE geoPrintPortrait    0    
#DEFINE geoPrintLandscape    1    
#DEFINE geoFindDefault    0    
#DEFINE geoFindAddress    1    
#DEFINE geoFindPlace    2    
#DEFINE geoFindLatLong    3    
#DEFINE geoFindOSGrid    4    
#DEFINE geoWindowStateMaximize    0    
#DEFINE geoWindowStateMinimize    1    
#DEFINE geoWindowStateNormal    2    
#DEFINE geoMiles    0    
#DEFINE geoKm    1    
#DEFINE geoPaneLegend    0    
#DEFINE geoPaneRoutePlanner    1    
#DEFINE geoPaneNearbyPlaces    2    
#DEFINE geoPaneNone    3    
#DEFINE geoMapNorthAmerica    1    
#DEFINE geoMapEurope    2    
#DEFINE geoImportFirstRowIsHeadings    0    
#DEFINE geoImportFirstRowNotHeadings    1    
#DEFINE geoImportExcelA1    0    
#DEFINE geoImportExcelR1C1    2    
#DEFINE geoImportAccessTable    0    
#DEFINE geoImportAccessQuery    4    
#DEFINE geoImportExcelSheet    0    
#DEFINE geoImportExcelNamedRange    4    

*!* Create a textfile for us to use as our data
LOCAL lcData, lcFile, lcMessage
WAIT WINDOW "Creating Text File...  ONE MOMENT PLEASE"  NOWAIT
lcMessage = "WORKING: 10% " + Replicate("|",5)
set message TO lcMessage
lcData = '"AK"    777.30' + CHR(13) + CHR(10) + ;
'"AL"    3578.05' + CHR(13) + CHR(10) + ;
'"AR"    244.50' + CHR(13) + CHR(10) + ;
'"AZ"    5654.00' + CHR(13) + CHR(10) + ;
'"CA"    25044.90' + CHR(13) + CHR(10) + ;
'"CO"    3609.25' + CHR(13) + CHR(10) + ;
'"CT"    12929.15' + CHR(13) + CHR(10) + ;
'"DE"    5729.10' + CHR(13) + CHR(10) + ;
'"FL"    5698.15' + CHR(13) + CHR(10) + ;
'"GA"    9360.55' + CHR(13) + CHR(10) + ;
'"HI"    790.50' + CHR(13) + CHR(10) + ;
'"IA"    7849.90' + CHR(13) + CHR(10) + ;
'"ID"    1021.90' + CHR(13) + CHR(10) + ;
'"IL"    21201.10' + CHR(13) + CHR(10) + ;
'"IN"    5954.50' + CHR(13) + CHR(10) + ;
'"KS"    1155.45' + CHR(13) + CHR(10) + ;
'"KY"    1683.35' + CHR(13) + CHR(10) + ;
'"LA"    3080.00' + CHR(13) + CHR(10) + ;
'"MA"    13330.05' + CHR(13) + CHR(10) + ;
'"MD"    1829.60' + CHR(13) + CHR(10) + ;
'"ME"    448.05' + CHR(13) + CHR(10) + ;
'"MI"    7181.65' + CHR(13) + CHR(10) + ;
'"MN"    35257.25' + CHR(13) + CHR(10) + ;
'"MO"    1722.35' + CHR(13) + CHR(10) + ;
'"MS"    1020.50' + CHR(13) + CHR(10) + ;
'"MT"    162.30' + CHR(13) + CHR(10) + ;
'"NC"    17925.10' + CHR(13) + CHR(10) + ;
'"NE"    4288.60' + CHR(13) + CHR(10) + ;
'"NH"    2455.30' + CHR(13) + CHR(10) + ;
'"NJ"    12089.65' + CHR(13) + CHR(10) + ;
'"NM"    490.20' + CHR(13) + CHR(10) + ;
'"NY"    24278.00' + CHR(13) + CHR(10) + ;
'"OH"    10402.75' + CHR(13) + CHR(10) + ;
'"OK"    1568.85' + CHR(13) + CHR(10) + ;
'"OR"    10865.95' + CHR(13) + CHR(10) + ;
'"PA"    12576.95' + CHR(13) + CHR(10) + ;
'"RI"    1552.75' + CHR(13) + CHR(10) + ;
'"SC"    4595.05' + CHR(13) + CHR(10) + ;
'"SD"    206.70' + CHR(13) + CHR(10) + ;
'"TN"    3365.35' + CHR(13) + CHR(10) + ;
'"TX"    26507.10' + CHR(13) + CHR(10) + ;
'"VA"    3457.00' + CHR(13) + CHR(10) + ;
'"VT"    1422.60' + CHR(13) + CHR(10) + ;
'"WA"    9772.75' + CHR(13) + CHR(10) + ;
'"WI"    5584.55' + CHR(13) + CHR(10) + ;
'"WV"    153.90' + CHR(13) + CHR(10) + ;
'"WY"    210.60'
lcFile = ADDBS(SYS(2023)) + "_"+SUBSTR(SYS(2015), 4) + ".txt"
=strtofile(lcData,lcFile)

WAIT WINDOW "Automating Mappoint...  ONE MOMENT PLEASE" NOWAIT
lcMessage = "WORKING: 25% " + Replicate("|",12)
set message TO lcMessage
**************************************************************
*!* Real work begins here
**************************************************************
PUBLIC oMap, oDataSet, oDataMap
LOCAL sTempDirectory, sDataSource

sDataSource = lcFile
oMap = CREATEOBJECT('mappoint.application')
lcMessage = "WORKING: 40% " + Replicate("|",20)
set message TO lcMessage
oDataSet = oMap.ActiveMap.DataSets.ImportData(sDataSource, , geoCountryUnitedStates, geoDelimiterTab)
lcMessage = "WORKING: 60% " + Replicate("|",30)
set message TO lcMessage
oField = oDataSet.Fields(2) &&Values in second field
oDataMap = oDataSet.DisplayDataMap(geoDataMapTypeShadedArea, oField, geoShowByZoomLevel, geoCombineByNone, ;
            geoRangeTypeDiscreteEqualRanges, geoRangeOrderHighToLow, 15, 8)
lcMessage = "WORKING: 80% " + Replicate("|",40)
set message TO lcMessage
oDataMap.LegendTitle = "Sales Totals by State"
lcMessage = "WORKING: 100% " + Replicate("|",50)
set message TO lcMessage
WAIT CLEAR
set message to
oMap.Visible= .T.
Erase (lcFile)

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close