place an image in the given lat, lang possitions.

Topics: Data Access, SharpMap Project, SharpMap v2.0
Feb 25, 2009 at 2:49 PM

   
   Hi,

       I have a requirement where in there needs to be display a map on the webpage with the marks given in backend database. (Lat, Lang possitions along with some associated parameters are in Database.) When we click on the mark it should be display some context menu with some links. 

It's all to be done in offline. internet will not be avilable in the system.

Application will be developed in ASP.Net 2.0 and SQLServer 2005.


For this Requirement i choose sharpmap and SQL server 2005 with spatial DB. Now i am looking to place images on the map with the data what i have. I am new to the sharpmap tool. can any one help regarding?


Thanks,
Srikanth

Coordinator
Feb 25, 2009 at 4:31 PM
Hi Srikanth, the following should help http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=Get%20features%20from%20a%20click%20on%20the%20map&referringTitle=How%20to... hth jd
Feb 26, 2009 at 11:44 AM
Edited Feb 26, 2009 at 11:45 AM
Thanks Johndiss..

I  have tried the follwoing but not Successfull .

AjaxMapControl1.BackColor = Color.White

 

Dim myLayer As SharpMap.Layers.VectorLayer = New SharpMap.Layers.VectorLayer("My layer")  

 

Dim connStr As String = "Data Source=.;Initial Catalog=Spatial;Integrated Security=True"  

 

'myLayer.DataSource = New SharpMap.Data.Providers.MsSql(connStr, "Place", "PlaceName", "ht  

 

myLayer.DataSource =

New SharpMap.Data.Providers.MsSql(connStr, "Place", "Lat", "HtmID")

 

 

 myLayer.MaxVisible = 40000

AjaxMapControl1.Map.Layers.Add(myLayer)

 

 

Coordinator
Feb 27, 2009 at 11:36 AM
Edited Feb 27, 2009 at 11:38 AM
Hi srikanthlade, did you get an exception or was the image blank? to start with I would remove the myLayer.MaxVisible line... Also your Geometry column seems to be called Lat and I am guessing this is a real/float column containing the Latitude, it needs to be a binary or image column holding the WKB of the whole geometry. If your database holds columns for Lon and Lat but no WKB you probably want to use the OledbPoint provider.. hth jd
Feb 28, 2009 at 7:53 AM
Edited Feb 28, 2009 at 10:50 AM

Hi

Thanks for your replay,
I am getting the Image i.e.. Map  but  Layer is not displaying.

As per your advice I remove the line "myLayer.MaxVisible"  and also changed the Database to hold image column
for WKB of whole geometry and we also use Oldbpoint provider.  But Still I am not getting the mark on the map from
 Spatical Database. So Please healp me and eargerly awaiting for your help

Thank u in advance

 

Coordinator
Feb 28, 2009 at 5:09 PM
Edited Feb 28, 2009 at 5:20 PM

Hi srikanthlade, how did you populate the WKB column? As a test you can execute this script against your database to create some test data:

CREATE TABLE MyPoints
(
PointId int identity(1,1) PRIMARY KEY,
Lon float Not Null,
Lat float Not Null
)

declare @minx float
declare @maxx float
declare @miny float
declare @maxy float

select @minx = -180, @maxx = 180, @miny = -90 , @maxy = 90

declare @width float
set @width = @maxx - @minx
declare @height float
set @height = @maxy - @miny

declare @counter int
set @counter = 0

while @counter < 100
begin

declare @x float
declare @y float

select @x = (rand() * @width) + @minx , @y = (rand() * @height) + @miny
insert into MyPoints(Lon, Lat) values(@x, @y)

set @counter = @counter + 1
end

then in your code you can use the data like so:

            VectorLayer points = new VectorLayer("points",
                                                 new OleDbPoint(
                                                     "server=XXXXXX;initial catalog=XXXXXXXXX;trusted_connection=true",
                                                     "MyPoints", "PointId", "Lon", "Lat"));

            map.Layers.Add(points);

Or

            Dim points As New VectorLayer("points", New OleDbPoint( _
                                                             "server=XXXXXX;initial catalog=XXXXXXXXX;trusted_connection=true", _
                                                             "MyPoints", "PointId", "Lon", "Lat"))
        map.Layers.Add(points)
Mar 2, 2009 at 7:07 AM
Thanks johndiss..it's working..you are great...

Is it work for AJAX Map also?
Coordinator
Mar 2, 2009 at 10:59 AM
It will work for any UI as it only affects the underlying map and data objects
Mar 2, 2009 at 11:29 AM
OK Fine...Thank you very much for your reply.

I have some more queries ...

  1. Currently we are displaying the points from all the records in the table. can i use any filter method here to retrieve some records and plot the map.
  2. i would like to add another column to the table Mypoints i.e., TYPE. now i have to show different colored points according to TYPE.
  3. Last one is, Need to show a context menu when i click on the point rendered on the map.


Thanks,
Srikanth.
Coordinator
Mar 2, 2009 at 11:43 AM
Hi Srikanth,

1) see OledbPoint.DefinitionQuery : it is effectively the 'Where' clause (though it adds the Where keyword automatically so you do not add it yourself) eg. oledbpoint.DefinitionQuery ="Population > 3000 and Class='Urban' "
2) You can add whatever columns you like, then you would use a CustomTheme to style based on attribute data
3) http://sharpmap.codeplex.com/Wiki/View.aspx?title=Get%20features%20from%20a%20click%20on%20the%20map&referringTitle=How%20to... should help also there are quite a few posts in the forums about it

cheers jd
Mar 3, 2009 at 10:02 AM
Thanks Johndiss..

 Added some images to the map according to records in DB. now i want to show some information, when i click on  mouse right button on some point it will show some context menu on client side..i mean using some java script. is it possible? so according to that lat, long position where the user will click, we will display some data right side of the map of that point.


Thanks,
Srikanth.

Coordinator
Mar 3, 2009 at 10:25 AM
Hi Srikanthlade, I don't use the Ajax Map but I am sure you can get a result with it, though you are likely to have to code a bit of it yourself. You can certainly get the click event from the map and convert it into real world coordinates which you can send back to the server using an async request and create the info box when the data returns. hth jd
Mar 3, 2009 at 10:29 AM
i am not using ajax map. Using simple map.
Coordinator
Mar 3, 2009 at 10:39 AM
Ah ok, then you will have the image click coordinates server side which you can convert to real world coordinates using map.ImageToWorld and use code similar to the link above to search for nearby features. Yyou almost certainly want to expand the bounding box, either by using the box.Grow method (so you grow the box by real world coordinates), or by creating two points in screen coordinates at +- a few pixels from the real click point and convert both to real world coordinates before building a BoundingBox from them. hth jd
Mar 4, 2009 at 10:45 AM

Hi

Thanks for your help Mr.Johndiss...
I have a query regarding SharpMap.

I need to show a sharp map of a particular region. Probably Bay of Bangal area. no pan. Only zoom is enough. now i looking to fixing the area of the map. 

Y axis: -16 (South) degrees to 24 degrees (North)
X axis: 76  (East) degrees to 100 degrees (East)


Thanks,
Srikanth
 

Coordinator
Mar 4, 2009 at 10:56 AM
Hi Srikanth try:

BoundingBox box = new BoundingBox(76, -16, 100, 24);
map.ZoomToBox(box);

hth jd
Mar 5, 2009 at 1:32 PM

I am very much thankfull to you Mr. John Diss

Please help me for these two queries

1) By giving BoundingBox method I got some selected area. 

BoundingBox box = new BoundingBox(76, -16, 100, 24);
map.ZoomToBox(box);

   But after ZoomIn, I have to Zoom only the selected area.  But its zooming all map area

 2)  I have to get grid lines on entire map and each box may shown as 30 miles of distance

 Thanks

Srikanth

 

Mar 5, 2009 at 1:43 PM

I am very much thankfull to you Mr. John Diss

Please help me for these two queries

1) By giving BoundingBox method I got some selected area. 

BoundingBox box = new BoundingBox(76, -16, 100, 24);
map.ZoomToBox(box);

   But after ZoomIn, I have to Zoom only the selected area.  But its zooming all map area

 2)  I have to get grid lines on entire map and each box may shown as 30 miles of distance

 Thanks

Srikanth