PDA

View Full Version : Shaded area datamaps - VBA



Swoop
03-07-2013, 09:30 AM
Can anyone point me in the right direction?

I'm basically getting nowhere using



set ObjDataSet = ObjDataSets.ImportData(zDatasource)
set ObjDataMap = ObjDataSet.DisplayDataMap(geoDataMapTypeShadedArea , , , , , , MPcolor)


And the error messages are really uninformative, like "The parameter is incorrect."

Eric Frost
03-07-2013, 09:39 AM
Do you have the book Programming MapPoint in .NET?

I think the examples in there are in C#, while I usually work in VB, but I still found the DisplayDataMap() examples very helpful.

Also, Richard Marsden wrote some articles published here --

http://www.mapforums.com/using-importdata-displaydatamap-part-1-3-importdata-method-18537.html

http://www.mapforums.com/using-importdata-displaydatamap-part-2-3-introducing-displaydatamap-18538.html

http://www.mapforums.com/using-importdata-displaydatamap-part-3-3-displaydatamap-parameters-18539.html

Swoop
03-07-2013, 09:44 AM
I really should learn to experiment more before posting. Cracked it appart from one tiny thing.....

Im using



Set ObjDataMap = ObjDataSet.DisplayDataMap(GeoDataMapTypeShadedArea , , , , , , MPcolor)


with MPcolor set to 13 (blue and red), however, on output it's using red for the high end and blue for the low.....I want it the other way round. Any ideas?

Eric Frost
03-07-2013, 10:00 AM
There are not so many options for those color ranges, and unfortunately it doesn't let you set your own ranges...

I wonder if you could flip your data? Maybe multiply everything by *-1?

Swoop
03-07-2013, 10:08 AM
Eric you're a genius.

Works perfectly.

Eric Frost
03-07-2013, 10:31 AM
Maybe that's what Microsoft intended people to do, lol.

Probably not as many people use these color ranges as they do Pushpins, but I think this is a bigger limitation than the limit of only 8 symbols in the Multiple Symbol map.

At least you can work around that limitation and use a macro to import along with custom symbols, but there's simply no way to get other color range patterns in there.

Eric

Swoop
03-08-2013, 06:45 AM
Nuther question relating to this....

I'm using the following code to map the data and then both paste a copy into an Excel worksheet directly and save a .ptm file:




zDataSource = SaveFile & "!Demog!V1:W" & Range("Demog!D65000").End(xlUp).Row
objApp.OpenMap SaveLoc & "patches.ptm"
Set ObjDataSets = objApp.ActiveMap.DataSets
Set ObjDataset = ObjDataSets.ImportData(zDataSource)
Set objDataMap = ObjDataset.DisplayDataMap(geoDataMapTypeShadedArea , , , , , , MPcolour)

Set objMap = objApp.ActiveMap
objMap.Altitude = Range("Menu!N19").Value
objMap.CopyMap
Sheets("Demog").Select
Range("A1").Select
ActiveSheet.Paste
objMap.SaveAs SaveLoc & "Demog.ptm", geoFormatMap, True



however......the copy that gets pasted into Excel is fine but the .ptm file that gets saved doesn't contain any data. What am I doing wrong?

Eric Frost
03-08-2013, 10:48 AM
I'm not sure this is going to help, and if it does exactly why, but I wonder if setting the objMap object sooner would help. Try rearranging the code like this and let is know if this helps.



zDataSource = SaveFile & "!Demog!V1:W" & Range("Demog!D65000").End(xlUp).Row
objApp.OpenMap SaveLoc & "patches.ptm"
Set objMap = objApp.ActiveMap
Set ObjDataset = objMap.Datasets.ImportData(zDataSource)
Set objDataMap = ObjDataset.DisplayDataMap(geoDataMapTypeShadedArea , , , , , , MPcolour)

objMap.Altitude = Range("Menu!N19").Value
objMap.CopyMap
Sheets("Demog").Select
Range("A1").Select
ActiveSheet.Paste
objMap.SaveAs SaveLoc & "Demog.ptm", geoFormatMap, True


Sorry I'm not sure this is going to help, but I can't think of anything else right now.

Eric