Regarding Zooming and Gridlines

Mar 5, 2009 at 11:34 AM
Edited Mar 6, 2009 at 7:22 AM

Hi all,

I had a query regarding Zooming. 

1) I bounded the selected area by giving the follwoing statements.

 Dim box As New SharpMap.Geometries.BoundingBox(Min x, Min Y, Max X, Max Y)
 myMap.ZoomToBox(box)

But while clicking on ZOOMIN, My requirement is, I have to ZOOM only this selected area.  But it is zooming the entire map

 2)  I have to get Gridlines on the entire map like a graph having 30 miles distance for selected BoundingBox.

Please any one help me

 Thanks

Chiranjeevi kumar

Mar 9, 2009 at 12:28 PM
Hi Mr. JohnDiss

Please help me  

I had a query regarding to get Gridlines on the Sharp Map

1) I have to get Gridlines on the entire map like a graph having 30 miles of  distance for selected  region of the BoundingBox.

Please any one help me

 Thanks

Chiranjeevi kumar

Coordinator
Mar 9, 2009 at 1:19 PM
Edited Mar 10, 2009 at 10:52 AM
Hi Chiranjeevi,
this depends on the coordinate system of your map,
for a projected coordinate system this is fairly easy, you just need two loops and create as set of Linestrings spanning the width of your map at 30mile intervals and the height of your map at 30 mile intervals
add the resultant linestrings to your map through a GeometryProvider.

so in pseudo code:

double minX, minY, maxX, maxY;
set minX = ......

double stepX, stepY;
set stepX = .....

List<SharpMap.Geometries.LineString> lines = new ....
//create the lines running from top to bottom
for(double currX = minX; currX <  maxX + stepX;currX += stepX)
{
    SharpMap.Geometries.Point point1, point2;
    point1 = new Point(currX, minY);
    point2 = new Point(currX, maxY);
    LineString line = new LineString(new List<SharpMap.Geometries.Point>(new Point[]{point1, point2}));
    lines.Add(line);
}
//create the lines running from left to right
for(double currY = minY; currY < maxY + stepY; currY += stepY)
{
    SharpMap.Geometries.Point point1, point2;
    point1 = new Point(minX, currY);
    point2 = new Point(maxX, currY);
    LineString line = new LineString(new List<SharpMap.Geometries.Point>(new Point[]{point1, point2}));
    lines.Add(line);
}

GeometryProvider prov = new GeometryProvider(lines);

layer.DataSource = prov;


 
For an angular coordinate system this is not so easy because the surface is curved and hence your 30 mile grid 'squares' will also be curved, if it doesn't matter for your purposes you may be able to approximate it by converting 30miles into an approximate angle and using a similar loop to the one described above - this will give you square 'squares' but the result would not be correct. hth jd
Mar 10, 2009 at 9:15 AM
Edited Mar 10, 2009 at 10:33 AM
Thanks for your replay Mr. Johndiss 

I have some questions here...

     1) lines.Add(line);

    i have seen the code there is no declaration of "lines". For this i checked sharpmap opensource code but there is no such class. 

  2)point1 = new Point(currX, minY);

    "Pointis Geometries.Point or System.Drawing.Point? Here  point1 is double but seems return type is different for both the cases.

       
Kindly Please replay...


Thanks,
Chiranjeevi Kumar

 

Coordinator
Mar 10, 2009 at 11:00 AM
Hi Chiranjeevi,
1)  lines is a List<LineString>
2) I had made a mistake, it is of type SharpMap.Geometries.Point I have updated the (still pseudo) code accordingly hth jd
Mar 10, 2009 at 4:34 PM

Thanks for your replay Mr. Johndiss 

    I am designing the code in VB.Net. But I am getting the error at 2nd statement

 

 1)   Dim Lines As New Generic.List(Of SharpMap.Geometries.LineString)  // for Generic Class Creation  // It is working fine

 

 

 2)  Dim prov As New SharpMap.Data.Providers.GeometryProvider(Lines) //

prov is showing as following error.

 

:\Demo1\Simple.aspx.vb(235) : error BC30518: Overload resolution failed because no accessible 'New' can be called with these arguments:
    'Public Sub New(wellKnownTextGeometry As String)': Value of type 'System.Collections.Generic.List(Of SharpMap.Geometries.LineString)' cannot be converted to 'String'.
    'Public Sub New(wellKnownBinaryGeometry() As Byte)': Value of type 'System.Collections.Generic.List(Of SharpMap.Geometries.LineString)' cannot be converted to '1-dimensional array of Byte'.
    'Public Sub New(geometry As SharpMap.Geometries.Geometry)': Value of type 'System.Collections.Generic.List(Of SharpMap.Geometries.LineString)' cannot be converted to 'SharpMap.Geometries.Geometry'.
    'Public Sub New(features As SharpMap.Data.FeatureDataTable)': Value of type 'System.Collections.Generic.List(Of SharpMap.Geometries.LineString)' cannot be converted to 'SharpMap.Data.FeatureDataTable'.
    'Public Sub New(feature As SharpMap.Data.FeatureDataRow)': Value of type 'System.Collections.Generic.List(Of SharpMap.Geometries.LineString)' cannot be converted to 'SharpMap.Data.FeatureDataRow'.
    'Public Sub New(geometries As System.Collections.Generic.List(Of SharpMap.Geometries.Geometry))': Value of type 'System.Collections.Generic.List(Of SharpMap.Geometries.LineString)' cannot be converted to 'System.Collections.Generic.List(Of SharpMap.Geometries.Geometry)'.

        Dim prov As New SharpMap.Data.Providers.GeometryProvider(Lines)
            ~~~~                        

Kindly please healp me

Thanks,

Chiranjeevi Kumar                              
Coordinator
Mar 10, 2009 at 5:23 PM
Ok , change the declaration of lines to:
Dim Lines As New Generic.List(Of SharpMap.Geometries.Geometry)

hth jd
Mar 11, 2009 at 9:04 AM
Thank you very much Johndis

At last I got it with your help., Thanks a lot
I had a query regarding Longitude and Latitude display.

1) I have to display Longitude and Latitude values in TextBoxes While Mouse Over on the Map

2) I have to move the Mouse Pointer to the given Cell point in the GridLines


Kindly Please help me

Thanks

Chiranjeevi Kumar
Coordinator
Mar 11, 2009 at 11:29 AM
use map.ImageToWorld to convert between screen and real world coordinates hth jd
Mar 11, 2009 at 1:28 PM
Edited Mar 11, 2009 at 3:18 PM
Thanks Johndiss

I am preparing Web application  in VB.Net of sharpmap.
 
For mouse over event  I have to write Client Side code i.e in Java Script. I tried but not getting.

Plz help me

1) I have to display Longitude and Latitude values in TextBoxes While Mouse Over on the Map.  But the code will be  in Client Side Code i.e  in Java Script

2) My Mouse Pointer had to display at the given Cell Point in the GridLines

Thanks

Chiranjeevi Kumar
Coordinator
Mar 11, 2009 at 5:38 PM
Hi Chiranjeevi, unfortunately I don't have any VB.net code lying around and I don't use the ajax map control either....
 But:
1) if you look at the javascript code for the ajax map control you will see that everything you need is already there: the ajax page in the web demo project demonstrates updating a 'status bar' with mouse over events
2) not sure what you mean

cheers jd
Mar 12, 2009 at 10:33 AM
Hi Mr. Johndiss

Thanks for your help, But

1) I used the Javascrip code of ajax map control in Simple Map .  But I am not getting Longitude and Latitude values on the status bar.  If you have the code or procedure in C# also plz send it.

2) My Cursor pointer had  move to the given Cell i.e given Longitude and Latitude value positions in the GridLies.

Thanks a lot

Chiranjeevi kumar
Coordinator
Mar 12, 2009 at 10:52 AM
I am confused. Are you using the ajax control or the simple control? (I don't use either) .
Mar 12, 2009 at 12:53 PM
Hi Johndiss
Thanks for speed replay,

 I am using Simple Map in Web demo project. As per your advice I saw the  Javascript code which was given for ajax map control in Web demo project.  but its not working in Simple Map control.


Thanks

Chiranjeevi kumar
Coordinator
Mar 12, 2009 at 1:10 PM
Edited Mar 12, 2009 at 1:21 PM
Sorry I had assumed [assume == ass (of)  u (and) me]  that you were using the ajax map control. I suspect that unless somebody else has got some code to share you will need to get stuck in and implement it yourself.. cheers jd
Mar 13, 2009 at 10:24 AM

Hi Mr Johndiss

Thanks for your help

With your help I got the Gridlines on the Map and I had a query regarding  showing the location

1) Cursor need to be point the specified cell in Gridlines (  i.e. User will give the Longitude and Latitude values ) and that location had to be shown in   
ZoomIn  position

Thanks

Chiranjeevi Kumar