Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding MapPoint 2004 for VFP V8

Status
Not open for further replies.

skrizoo

Programmer
Mar 9, 2001
8
CA
Our logistics planning system (VFP8) includes MapPoint for display of data (location of plants, depots, etc.). We have been successful importing data, displaying data and working with maps. The user clicks a button and our VFP code takes over.

But we are stuck in that we are not able to display pushpin data in the individual ballons (such as volume and capacity for a location). I am attaching that part of the code we have that is supposed to do the job, but it simply is not working.

I suspect that the problem is related to the use of the method "setfieldsvisibleinballon"

Any suggestions would be extremely useful!
Thanks
Jerry Bendiner
TechnoLogix
Toronto, Canada

HERE IS THE CODE FOR THE SECTION OF THE PROGRAM
*
#DEFINE geoImportExcelSheet 0
#DEFINE geoCountryMultiCountry 39070
#DEFINE geoDataMapTypePushpin 4
#DEFINE geoMapFontSmallest 4
myApp = CREATEOBJECT("MapPoint.Application")
myMap = myApp.NewMap()
myMap.MapFont = geoMapFontSmallest
myApp.UserControl = .T.
myApp.WindowState = 0 && Maximized.
myMap.MapStyle = 2 && Data
myApp.PaneState = 3 && Don't show the legend pane.
myApp.Toolbars.Item("Location and Scale").Visible = .f.
myApp.Toolbars.Item("Drawing").Visible = .f.
dimension showfield[4]
currdir=alltrim(sys(2003))
*
* import plant data
*
myfile = "d:\mapdata\plants.xls!plants!"
DSplant = myApp.ActiveMap.DataSets.ImportData(myfile, , geoCountryMultiCountry, , geoImportExcelSheet)
DSplant.name="Plants"
DSplant.Symbol= 57
showfield[1]="city"
showfield[2]="state"
showfield[3]="country"
showfield[4]="volumen"
DSplant.setfieldsvisibleinballon showfield
DSplant.fieldnamesvisibleinballoon=.t.
myApp.visible=.t.
DSplant.DisplayPushpinMap
 
Ok, this is some stuff off the top of my head that may help with the problem...

DSplant.setfieldsvisibleinballon showfield

...Sending an array to this method should read like:

DSplant.setfieldsvisibleinballon(@showfield)

...in VFP. Also, if that doesn't fix it then you may want to take a look at the COMARRAY( ) Function in the VFP helpfile.


boyd.gif

 
In response to your other thread asking about COMARRAY() use:

vfphelpfile said:
Note that COMARRAY( ) is only used when arrays are passed to COM objects using the following syntax:

oComObject.Method(@MyArray)

From the preceeding quote you can see that you will have to use the syntax:

DSplant.setfieldsvisibleinballon(@showfield)

Please note that no other syntax will do. You must do it this way to have even a chance for success.


The way in which you would use the COMARRAY() depends on what the requirements are for the setfieldsvisibleinballon.

Question though, are you misspelling the name of the funciton or is it misspelled like that...

setfieldsvisibleinballon

or is it:

setfieldsvisibleinballoon

...this could be the cause of your problem right there.

Are you receiving any error messages that might help figure out what the problem is?

Ok, back to COMARRAY()...

If the array that your COM object wishes to receive is one's based or zero based, this will make a difference (notice 10 or 11 of the nNewVal parameter).

If the array that your COM object wishes to receive is to be passed By Val or By Ref then this will make a difference in the way in which you use the COMARRAY() function (notice 0, 1, 10, and 11 of the nNewVal parameter). So, according to the VBA helpfile section of Mappoint what is it expecting? I would guess that it is Zero Based and passed ByVal given that it is VBA, but I've seen others.

Once you have that figured out then it is just a matter of calling the COMARRAY function prior to passing the array to the mappoint function...

COMARRAY(myApp,0)
DSplant.setfieldsvisibleinballoon(@showfield)

you may also try using something like:

COMARRAY(DSplant,0)
DSplant.setfieldsvisibleinballoon(@showfield)

boyd.gif

 
wow. You have given me many options to look at here. I really appreciate your input.

I finally figured out the problem by looking at the error message as you suggested which said:

OLE IDispatch exception code 0 from MapPoint.Application.NA11:Type Mismatch


This led me to discovering that I was sending the name of the field in the array rather than the address of the name of the field. This in combination with setting the @sign in front of the array fixed it.

It works now. This has been many days and months of aggravation. Thank you so much for your assistance.


 
Glad to hear you got it working.

I was sending the name of the field in the array rather than the address of the name of the field

You mean you sent the contents of the field instead of the field name and this fixed it? Also, was the spelling incorrect for that one function call (ballon rather than balloon)? Maybe you could post the working snippet of code so that other could benefit if they stumble across this thread in the future.

boyd.gif

 
Everything had been spelled fine. It was just that I was passing the wrong parameters to Mappoint.

The dataset contains a file with field names city, state, country, volumen.
As you can see below, I had first defined the array members as the name of the fields which didn't work.
Once I redefined the array with the dsplant.fields[1], [2], [3] [4], it worked fine. That combined with having to have an array passed by preceding the array name with an @ sign

#DEFINE geoImportExcelSheet 0
#DEFINE geoCountryMultiCountry 39070
#DEFINE geoDataMapTypePushpin 4
#DEFINE geoMapFontSmallest 4
myApp = CREATEOBJECT("MapPoint.Application")
myMap = myApp.NewMap()
PUBLIC array showfield[4]
SELECT 16
USE tempdata EXCLUSIVE
COPY TO plants TYPE xl5
myfile = sys(5)+alltrim(sys(2003))+"\plants.xls!plants!"

DSplant = myApp.ActiveMap.DataSets.ImportData(myfile, , geoCountryMultiCountry, , geoImportExcelSheet)
DSplant.name="Plants"
DSplant.Symbol= 57
*showfield[1]="city"
*showfield[2]="state"
*showfield[3]="country"
*showfield[4]="volumen"
showfield[1]=dsplant.fields[1]
showfield[2]=dsplant.fields[2]
showfield[3]=dsplant.fields[3]
showfield[4]=dsplant.fields[4]
DSplant.fieldnamesvisibleinballoon=.t.
DSplant.setfieldsvisibleinballoon(@showfield)
DSplant.fieldnamesvisibleinballoon=.t.
myApp.visible=.t.
DSplant.DisplayPushpinMap

Ralph Skrzydlo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top