How to Add a new Layer in web application?

Apr 4, 2008 at 1:28 AM
Hello,

I've provide an 'Add Layer' button in my web application? is there any source code in VB.net that i can refer to? Thank you..
Developer
Apr 4, 2008 at 1:59 PM
There is no VB code in the sharpmap project.
Joane3005 has uploaded some VB.net patches, maybe they can be of help.
http://www.codeplex.com/SharpMap/SourceControl/PatchList.aspx
Apr 5, 2008 at 2:49 AM
yup, i like to work with vb.net instead of c# even c# is much better,

viva, what do u really want to do with the button "addlayer' , do u want someone upload a new shapefile from local computer to web server, or do u have any shapefile already on the server just to be activated by pressing that button ?
Apr 10, 2008 at 3:16 AM
Hi joanne,

Yup, i want to upload a new shapefiles from local computer to web server. Is it possible that i can do like that?
Apr 11, 2008 at 4:33 AM


joane3005 wrote:
yup, i like to work with vb.net instead of c# even c# is much better,

viva, what do u really want to do with the button "addlayer' , do u want someone upload a new shapefile from local computer to web server, or do u have any shapefile already on the server just to be activated by pressing that button ?



Hi joanne,

Its me again.First of all, it is not a 'ADD Layer' button but it is a 'Search' button. Actually how my web application run are like below procedure :-

1) Once i run the web application, my country map(shapefiles) will be displayed.
2) I've gps coordinates store in my database use to display a point when i query it by fill up empty field that i've provide in my web application. More easy to say, it is a search function method.
3) Once i've fill up all the field and i click the 'Search' button.
4) i do some SQL command to get the gps coordinates from dB. Using that gps coordinates, i create a new shapefiles automatically and store it into 'App_Data'.
5) once i click the 'search' button, a shapefiles that i've just created will be displayed/added into map.

How do i add/display the shapefiles into the map? Really need help.

viva
Apr 12, 2008 at 6:50 AM
I'm using the C# sample, hope this could help...

If you wanna display a new shp file, you need to do sth with the MapHelper.cs(which initializes the map) in 'App_Code', and there're lots of configs you need to set. You'd better add some config options in the upload page, and update the MapHelper.cs also.
Apr 15, 2008 at 2:33 AM
How do i set the configs. can u give some source code that i refer to?
Apr 16, 2008 at 10:00 AM


viva wrote:
How do i set the configs. can u give some source code that i refer to?


Here're some codes to initialize the map in the 'countries.shp' file, and it's in the 'App_Code' folder.

You need to update your MapHelper.vb and reload the page(or call the ViewChanging event) to display the new map.

'Set up the countries layer
Dim layCountries As New SharpMap.Layers.VectorLayer("Countries")
'Set the datasource to a shapefile in the App_data folder
layCountries.DataSource = New SharpMap.Data.Providers.ShapeFile(HttpContext.Current.Server.MapPath("~\App_data\countries.shp"), True)

'Set fill-style to green
layCountries.Style.Fill = New SolidBrush(Color.Green)
'Set the polygons to have a black outline
layCountries.Style.Outline = System.Drawing.Pens.Black
layCountries.Style.EnableOutline = True
layCountries.SRID = 4326

...

'Add the layers to the map object.
'The order we add them in are the order they are drawn, so we add the rivers last to put them on top
map.Layers.Add(layCountries)

I'm just a newbie, sorry for couldn't help more.