ThinkGeo.com    |     Documentation    |     Premium Support

SQLFeature

Hi


I'm evaluating the product and I'm trying to figure out the following.


After doing this


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

           Map1.MapTools.Logo.Enabled = False

            Map1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"))

            Map1.CurrentExtent = New RectangleShape(3552783.51957, -2927834.3764, 3563121.62765, -2933681.80906)

            Map1.MapUnit = GeographyUnit.Meter

            Map1.MapTools.OverlaySwitcher.Enabled = True

            Map1.MapTools.PanZoomBar.Enabled = False

            Map1.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.LongitudeLatitude

            Map1.MapTools.MouseCoordinate.Enabled = True

            Dim yahoo As New YahooOverlay("Yahoo Map")

            yahoo.JavaScriptLibraryUri = New Uri(ConfigurationManager.AppSettings("YahooUri"))

            yahoo.YahooMapType = YahooMapType.Regular

            Map1.CustomOverlays.Add(yahoo)

            ''''''''''''''''''LoadAMapFromMsSQL2008()'''''''''''''''''

        End If

    End Sub


I want to draw a feauture layer over this yahoo map. data coming from sql, but this does not work


    Private Sub LoadAMapFromMsSQL2008()

        Dim connectString As String = "User ID=tdt_data;Password=tdt_data123;Data Source=GUSS-PC/TDT3_Data;"

        Dim sql2008Layer As New MsSql2008FeatureLayer(connectString, "Table_1", "aaa")

        ' sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1

        '  sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

        Map1.StaticOverlay.Layers.Add(sql2008Layer)

    End Sub


Can you give me an example of how to use the yahoo map as a base map, and then draw features over it from sql.

The idea is to use wgs84 features in a geomety field. Example: LINESTRING (31 -25, 26 32)


 


 



Guss, 
  
 The problem is that the CustomOverlays and the “shortcut” overlays (like StaticOverlay, DynamicOverlay) can not be used at the same time. When using CustomOverlays, the “shortcut” overlays are automatically disabled. You need to create and add all the overlays to the CustomOverlays collection. Here are the modified codes: 
 
Private Sub LoadAMapFromMsSQL2008()
        Dim connectString As String = "User ID=tdt_data;Password=tdt_data123;Data Source=GUSS-PC/TDT3_Data;"
        Dim sql2008Layer As New MsSql2008FeatureLayer(connectString, "Table_1", "aaa")
        sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1
        sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

        Dim proj4 As New Proj4Projection()
        proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326)
        proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
        sql2008Layer.FeatureSource.Projection = proj4

        Dim shapeOverlay As New LayerOverlay("Shape Overlay", False, TileType.SingleTile)
        shapeOverlay.Layers.Add(sql2008Layer)
        shapeOverlay.TransitionEffect = TransitionEffect.None

        Map1.CustomOverlays.Add(shapeOverlay)
End Sub
 
 Note: YahooMap uses the projection 900913 (the same one as GoogleMap), and the layers on it should be converted to the same projection.  
  
 Thanks, 
  
 Ben 


Thanks Ben


I'll give it a try!



Hi Bed…the code seems to be working because I see the layer on the layer legend box and also the unlicensed watermark, but I don;'t see my line. 
 Sorry, maybe I’m not uderstanding the projections. 
 I have this in my database: 
 2 LINESTRING (31 -25, 26 32) 
 3 LINESTRING (-25 31, 32 26) 
 4 LINESTRING (-25 31, 32 26) 
 5 LINESTRING (3552783 -2927843, 3563121 -2933698) 
 6 LINESTRING (3552783 -2927843, 3563121 -2933698) 
 7 LINESTRING (3552783 -2927834, 3563121 -2933681) 
  
 I’m trying coordinates as well as those other values, but dont see my lines. 
 The map extent is Map1.CurrentExtent = New RectangleShape(3552783.51957, -2927834.3764, 3563121.62765, -2933681.80906) 
  
 If disabled and enbled these to line just incase it zoom levels that is not correct 
 ’ sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1 
         'sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 
  
 but I’m sure I’m having some other logic misunderstanding somewhere. 


Guss,  
 Here are some possible reasons. 
 1, LineString2 to LineString 4 seem using Decimal Degree and LineString5 to LineString7 seem using YahooMap’s projection. Just wonder is that right? Do you really want to show all the lines on one map? I think LineString 2~4 should be the source data in Decimal Degree and LineString5~7 should be the one projected already, maybe something wrong here. 
 2, LayerOverlay is baseOverlay by default; you need to set it to false if you want to make it on top of another baseOverlay (YahooMap). On the OverlaySwitcher, the shapeOverlay should get a corresponding checkbox, not a radio button.  
  
 Let me know if you have any issues. 
  
 Thanks, 
  
 Ben 


Hi Ben 
  
 Linestring 2 to 7 is just to show that I’ve tried different combinations. 
  
 I still can’t get a single line to show. 
 Lets assume that I want to work with only WGS84 (4326) and also that all my data is coordinates. For basemaps and overlays I’m using google or yahoo. 
  
 1. Am I assuming right if I say that I have to project the google / yahoo first to 4326? 
 2. Set mapunits to coordinates? 
 3. supply the current extent in coordinates? 
  
 Regards 
 Guss

Hi David / Ben


It seems that I'm missing a big set of logic here.


So in my SQL database the id column is called "id" and the WKT is stored in a geometric field called "feature"


In my dataconnection the id is now specified as "id"


how do iget the shapes out of the database so that they draw on the screen?

Querytools?



Guss


Here are some tips for you, 
1.         We can’t change the 3rd part overlays (GoogleMap / YahooMap / VirtualEarth overlays) so we can only convert our LayerOverlay to follow their Overlays. That means we cannot convert their projection to 4326, but only convert our feature data from 4326 to their projection. So we should set the map unit to meter according to their projection, and current extent will also be in meter.
2.         The third parameter of MsSql2008FeatureLayer’s constructor should be the name of the column containing unique identifier for features. As you mentioned, in SQL database the id column is called "id", so it should be “id” for your case.
                  MsSql2008FeatureLayer msLayer = new MsSql2008FeatureLayer(connectString,"Table_1", “id”, 900913);
 
3.         The data in column “feature” should be with a SRID information, if the WKT is “LINESTRING (3552783 -2927834, 3563121 -2933681)”, the value of the “feature” should be “geometry::STGeomFromText('LINESTRING (3552783 -2927843, 3563121 -2933698)', 900913))”,
 
If you still have the problem, could you paste a piece of sql data (could be the script or backup file), that’ll be much easier for us to recreate and find out what happened.
 
Any questions please let us know
 
Thanks,
 
Ben