Problems to add shapefile in a map

Apr 9, 2013 at 10:27 AM
Edited Apr 9, 2013 at 10:29 AM
This Source failedin order to add layers in a map.

Private Sub Command1_Click()
Dim sf As MapWinGIS.Shapefile
sf.Open("C:\Cities\Cities.shp", Null)
Map1.AddLayer(sf, True)

End Sub

I am working with VB6
Apr 12, 2013 at 10:12 PM
You didn't post what errors you got.
Apr 16, 2013 at 6:29 AM
I have the same problem, Windows 7 Ultimate 64 bits with Visual Studio 2010 (I have 2 different computers with the same combination). Installed 64 bit ActiveX, 32 bit ActiveX, connect ActiveX from MapWindow (these are 3 different scenarios) and I tried C# code:

MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
sf.Open("C:\temp\data\TorreDeCoelheiros_5Centroids.shp", null);
axMap1.AddLayer(sf, true);

the shape never appears. Sometimes after closing the software the visual studio gives an error in Main() : Application.Run(new Form1());

Tried the same on Windows XP with Visual Studio 2008, works like a charm.

Thanks for any suggestions.
Coordinator
Apr 22, 2013 at 12:10 PM
Can you check if sf.Open returns false?
If so what error message do you get: sf.get_ErrorMessage(sf.LastErrorMsg);
Apr 22, 2013 at 1:08 PM
Yes those are OK (it is true and no error message) The amount of layers is 1 at the end of the procedure.

The thing is if I run the compiled executable it displays the map. If I run it through debugger the Map component is empty.
I found a similar thread here : https://mapwingis.codeplex.com/discussions/396750
but I am not sure how to check for the dependencies of the ActiveX?
Apr 26, 2013 at 5:35 AM
I have the same problem.

My PC is Windows7 32 bits with Visual Studio 2010.
I installed MapWindowx86Full-v48Final-installer.exe.

<VB.NET>
Dim sfWorld As New MapWinGIS.Shapefile
sfWorld.Open("D:\work\world_adm0.shp")
mapMain.AddLayer(sfWorld, True) <- Access Violation occured

I tried same code with Windows XP 32 bits with Visual Studio 2010.
It worked.

And,I uninstalled MapWindow4.8 from Win7 PC and installed MapWindow4.7.
And try again.It worked.
Coordinator
Apr 26, 2013 at 8:58 AM
Edited May 1, 2013 at 12:22 PM
Could you all try to uninstall all version of MapWindow and install the latest beta and let me know if this solves your problem.
You can get the latest beta at http://tinyurl.com/mwMonthly
And can you check before installing the beta if you have .NET v3.5 installed?
And it might be helpful to start the installer as admin: right click on the downloaded exe and select 'run as admin'


Paul
Coordinator
Apr 26, 2013 at 2:28 PM
This error also occurs when the file you are opening is in use by another application. Try opening a different file.

----------------------------------
Daniel P. Ames, Ph.D., P.E.
Associate Professor, Civil & Environmental Engineering
Brigham Young University, Provo, Utah


Apr 26, 2013 at 3:21 PM
Thanks,Paul and Daniel.

I uninstalled 4.8-Final and installed 4.8-Beta as admin,
but Access Violation occurred at the same point.

I've not used the file by another application.
And error occurred with a different file.

Why 4.7 works but 4.8 doesn't work?
Coordinator
May 1, 2013 at 12:27 PM
Can you verify you have .NETv3.5 installed on your system?
Did you ran Windows Update lately?
Can you try to re-install the VC++ binaries: http://svn.mapwindow.org/svnroot/InstallationProjects/4.8/Documents/vcredist_x86_2008.exe

And can you download dependency walker: http://www.dependencywalker.com/ and drop the ocx on it.
It should not report any missing dlls.
May 2, 2013 at 7:11 AM
Thanks for advice.

.NET Framework3.5.1 and 4.0 are installed in my PC,
and I ran Windows Update lately.

I tryed to re-install the VC++ binaries,
but the same error occurred.

I've found that the Access Violation occurs
when I 'm debuging the source in Visual Studio,
but the Access Violation does not occur when I run the exe file
which is compiled with Visual Studio.(Even use V4.8 Final)

And I try Dependency Walker, the result was "IESHIMS.DLL not found".
But IESHIMS.dll is in the %ProgramFiles%\Internet Explorer directory.
Coordinator
May 3, 2013 at 7:30 AM
I believe "IESHIMS.DLL not found" is a common warning, nothing to worry about.
MapWinGIS is not directly using this dll.

As I understand it correctly you only have the problems while debugging the ocx? Or are you debugging your own application?
If you are debugging the ocx you might consider debugging your application instead and use the ocx as a 'black box'.
May 7, 2013 at 2:26 AM
Sorry for my late reply.
As I understand it correctly you only have the problems while debugging the ocx? Or are you debugging your own application?
If you are debugging the ocx you might consider debugging your application instead and use the ocx as a 'black box'.
Sorry,I couldn't understand well what you mean.
(I'm not good at English.)

I was debugging my own application with MapWinGIS.ocx.
I added the ocx to VS2010 ToolBox and added the Map Control to my form,
like this.
http://en.youscribe.com/catalogue/tous/professional-resources/it-systems/mapwingis-activex-development-tutorial-518157
Coordinator
May 8, 2013 at 7:19 AM
Hiromi,

If I understand it correctly you have installed the full installer of MapWindow.
Can you upgrade your binaries using this procedure: http://www.mapwindow.org/phorum/read.php?4,24284

Next start MapWindow, not your own application and open the shapefile.
If you don't have trouble opening the shapefile the problem is in your application.
If you do have trouble the problem might be with your shapefile.
Either way can you send me the source code of your application and the shapefile so I can have a look?
Please send it to bontepaarden[AT]gmail[D0T]com


Paul
May 9, 2013 at 8:47 AM
Thanks a lot,Paul.

I upgraded my binaries,but the same error occurred,
And MapWindow GIS has no problem.

My souce code is very simple.

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    LoadData()

End Sub

Private Sub LoadData()

    Dim sfWorld As New MapWinGIS.Shapefile

    OpenFileDialog1.Filter = "Shape Files (.shp)|*.shp|All Files (*.*)|*.*"
    If OpenFileDialog1.ShowDialog = DialogResult.OK Then
        sfWorld.Open(OpenFileDialog1.FileName)
        AxMap1.AddLayer(sfWorld, True)
    End If

End Sub

End Class

That's all.

And the Shape file is "world_adm0.shp".It's not special.

If I don't use AxMap,I can debug in IDE and no error.
For example,the code which convert shape file to KML file is OK.