PDA

View Full Version : add pin more quicly



zanabonir
01-09-2012, 04:50 PM
Dear forum

im using the mappoint 2010 ocx whit c# (but language is not important )
and many time i must excract coordinate from db and push on map.
Time for push 500 pin is almost 10 sec...long time to wait.

For add a pin i do:

MapPoint.Location location = axMappointControl1.ActiveMap.GetLocation(......)

and

Pushpin pin = axMappointControl1.ActiveMap.AddPushpin(location,. ....)

Somethink better ?

Thanks very much

Eric Frost
01-10-2012, 08:26 AM
I don't think this can really be sped up much the way you are doing it, AddPushpin just takes a while.

One idea though, would be that instead of adding individual pushpins, instead set up a CSV file with the coordinates and then import the CSV in one swoop using ImportData. That should actually be a lot faster?

There were some recent articles by Richard Marsden on ImportData, take a look in the articles section
MapPoint Articles - MP2K Magazine (http://www.mp2kmag.com/articles.asp)

Also, see the help file.

Let us know how it goes!

Eric

zanabonir
01-10-2012, 03:10 PM
Thanks Mr Frost

I try the example in the link you give me only up to the ImportData point,
and is working.
Then I build a file whit coordinate Latitudine and Longit inside, and try to
use .ImportData on this file.
I get a error "no method for thi colum" (i get in italian)

I belive the field State e Country are mandatory (i try to alterate the Sales.txt
and when delete this fiel i get same error)
Of course this must be because the .ImportData metod have a Geocountry that must be specified.

But,also if i import Latitude and Longitude (for example i can do this if i substitute in the Sales file the lat and long inthe column A-Sales and B-Sales)
also no way to put a pushpin.
I used the DisplayDataMap(MapPoint.GeoDataMapType.geoDataMapT ypePushpin,..

Please help
Roberto
So please, if you have some

Eric Frost
01-10-2012, 03:13 PM
Are you able to import it through the regular interface? e.g. clicking on Data | Import Data Wizard (or the Italian equivalent).

If so, and you have no problems with this, then I would expect it's an issue with your code syntax.

If you still have problems, it might help if you post more details:

1. your text file
2. your code

Eric

zanabonir
01-10-2012, 04:16 PM
Thank Much Mr Frost

I try to import from interface and it work...i see all the way.

This help me also to undestand better some, and now im able to import my file.txt. also via code c#.

Here is some line (is long some thousend):

Country Latitudine Longitudine
Italy 45,494583 9,184033
Italy 45,494567 9,184
Italy 45,494533 9,183983
Italy 45,4945 9,18395

Whit interface work also if italy is not present (but interface suggest me to put in first column the country)

So now i try to visualize via code this imported data.
Following the example you show me before, i write:

object Lat = 2; //Position of variables
object Lon = 3;

object[] datafields;
datafields = new object[2]; //Number of variabiles
datafields[0] = DS.Fields.get_Item(ref Lat);
datafields[1] = DS.Fields.get_Item(ref Lon);

where 2 and 3 is position of data in file.

So i write the code below,but some parameter i not undestand ,and so error-incorrect parameter -go out

object[] arrayOfSymbols = new object[1];
arrayOfSymbols[0] = (int)(218 ); //Simbol 218


datamap = DS.DisplayDataMap(MapPoint.GeoDataMapType.geoDataM apTypeMultipleSymbol,
datafields,
MapPoint.GeoShowDataBy.geoShowByLatLong,
MapPoint.GeoCombineDataBy.geoCombineByNone,
MapPoint.GeoDataRangeType.geoRangeTypeDiscreteEqua lRanges,
MapPoint.GeoDataRangeOrder.geoRangeOrderDefault,
6, //COLOR
2, //Number of variabiles
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
arrayOfSymbols
);

many thank for time

Eric Frost
01-10-2012, 04:30 PM
My pleasure!

Glad you got it to work and that's awesome that you followed up with the working code to show how you did it.

Happy coding!

zanabonir
01-10-2012, 04:47 PM
Thank Mr Frost

please a little help again.

I get a error when try to display data via code,and, also work arount, i cant find solution.

Code i write is:


datamap = DS.DisplayDataMap(MapPoint.GeoDataMapType.geoDataM apTypeMultipleSymbol,
datafields,
MapPoint.GeoShowDataBy.geoShowByLatLong,
MapPoint.GeoCombineDataBy.geoCombineByNone,
MapPoint.GeoDataRangeType.geoRangeTypeDefault,
MapPoint.GeoDataRangeOrder.geoRangeOrderDefault,
6,
2,
Type.Missing, //array custom value
Type.Missing, //Array di custo name
Type.Missing, //div
Type.Missing, //array di datafiellabel
arrayOfSymbols
);

What parameter is wrong ?
Many hello

Eric Frost
01-10-2012, 04:55 PM
What is the error?

Let me guess: "The parameter is incorrect."

MapPoint coding is generally pretty easy for any VBA programmer, some learning curve but nothing too onerous, however you have hit upon probably the most frustrating thing.

Wouldn't it be nice if they told you which parameter? And even better, why?

In any case, read Richard Marsden's articles (linked earlier) again, he discusses this directly. Although I mentioned they cover ImportData, the real meat of the articles is actually DisplayDataMap!

Also, it's hard to tell what specifically is wrong with your code without

1. the data
2. how the arrays are defined and set up

Let us know how it goes and if we can be of more assistance.

Eric

Allen
01-10-2014, 03:31 AM
Nice information to add pin quickly. Its really a great sharing. All posts are informative. Thank you Eric for sharing this article. I have read it.

citrix_99301
01-23-2014, 10:47 PM
Eric:

I'm having a similar issue with ImportData and I'm trying to figure out what I'm missing. I can import my source CSV file (snippet below) directly into MapPoint but not through the C# COM interface. It fails on oDataSets.ImportData with an exception message "No matching method defined for these fields".

Route,AccountKey,Latitude,Longitude
BoLCC,331392,43.5235,-116.562
BoLCC,13479,43.6501,-116.694
BoLCC,303596,43.4847,-116.63
BoLCC,340725,43.538,-116.577
BoLCC,14279,43.4738,-116.494
BoLCC,338142,43.6245,-116.651
BoLCC,339044,43.5478,-116.568
BoLCC,323043,43.572,-116.603
BoLCC,305588,43.5346,-116.592


The code snippet I'm using to import is below:


// create column mappings array template
object[,] oArray = new object[4, 2];
oArray[0, 0] = "Name";
oArray[0, 1] = MapPoint.GeoFieldType.geoFieldName;
oArray[1, 0] = "AccountKey";
oArray[1, 1] = MapPoint.GeoFieldType.geoFieldName2;
oArray[2, 0] = "Latitude";
oArray[2, 1] = MapPoint.GeoFieldType.geoFieldLatitude;
oArray[3, 0] = "Longitude";
oArray[3, 1] = MapPoint.GeoFieldType.geoFieldLatitude;



MapPoint.Map oMap = this.axMapPoint.ActiveMap;
MapPoint.DataSets oDataSets = oMap.DataSets;
Object oName = (object)ImportRoutes[i].Route;
MapPoint.DataSet oDS = oDataSets.ImportData(ImportRoutes[i].Path, oArray,
MapPoint.GeoCountry.geoCountryUnitedStates,
MapPoint.GeoDelimiter.geoDelimiterComma,
GeoImportFlags.geoImportFirstRowIsHeadings);
oDS.Symbol = MySymbolList[ ImportRoutes[i].PushPinIndex ].iID;


Any hints would be much appreciated. If I figure it out, I'll post my solution here.

Thanks,

Andre Ranieri

citrix_99301
01-23-2014, 11:58 PM
Please disregard my earlier post. I declared latitude twice in my object array.

I hope my solution posted above helps someone else in the future.

Regards,

Andre Ranieri

alhaq369
01-30-2016, 08:32 AM
Wow! This is wonderful post and great advise. Thank you so much for your post.