none
Sql Spatial to Bing Maps (Silverlight)

    Question

  • I see this question has been asked many times, but wasn't sure if SL 4.0 has change anything. What is the best practice for getting SqlGeography data (polygon for instance) overlaying my SL Bing map?

    As of now, my plan is to have my webservice query the database, break the SqlGeography into an encrypted Long/Lat list (per this: http://www.soulsolutions.com.au/Articles/Encodingforperformance.aspx) - send this excrpyted string to the SL Client, and build a Polygon over the map.

    I wasn't sure if there was a better way yet? Thanks.

    Wednesday, August 11, 2010 3:08 PM

Answers

  • The issue is that SqlServer.Types.dll (the library that contains the SqlGeometry and SqlGeography types and methods) is not a Silverlight-compatible assembly, because it contains non-managed code. Therefore you can't work directly with geography or geometry data in Silverlight (any version) - you need to find some other medium in which to send it from SQL Server to Silverlight.

    Encrypted lat/longs work well, or simple WKB also does the job. WKT and GML are good formats for human-readability but generally a bit too verbose if you're looking for the best performing solution.


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Wednesday, August 11, 2010 3:42 PM

All replies

  • The issue is that SqlServer.Types.dll (the library that contains the SqlGeometry and SqlGeography types and methods) is not a Silverlight-compatible assembly, because it contains non-managed code. Therefore you can't work directly with geography or geometry data in Silverlight (any version) - you need to find some other medium in which to send it from SQL Server to Silverlight.

    Encrypted lat/longs work well, or simple WKB also does the job. WKT and GML are good formats for human-readability but generally a bit too verbose if you're looking for the best performing solution.


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Wednesday, August 11, 2010 3:42 PM
  • Thanks for the info. I'm considering the Ajax sdk over the Silverlight approach, what are the dis/advantages for using one over the other? From a mapping/user perspective that is.
    Wednesday, August 11, 2010 3:52 PM
  • Both technologies run client-side. AJAX is more widely-supported (pretty much any browser has javascript enabled). Silverlight obviously only aims at those users with the silverlight browser plugin.

    AJAX is not well-suited for complex mapping, graphics work etc. It will choke if you try to draw complex polygons, or too many points at once. Silverlight will handle more points, and can handle multimedia (e.g. pushpins can be represented by video clips, and map scaling is smoother) but still has limitations before you start to experience UI responsiveness issues.

    If you have a lot of data to plot, I'd strongly recommend that, whether you go for AJAX or Silverlight, you consider creating a raster tile layer of your data rather than trying to draw vector shapes. Raster tiles are the way in which the default road and aerial modes are displayed in Bing Maps and you can display as much complex information as you want, because they are simply .PNG / .JPG files. The downside is that they cannot be interactive (you cannot handle a mouseover event on a raster shape)...


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Wednesday, August 11, 2010 4:02 PM
  • Good info, next question is: What is a lot of data, or too many points? and how do I determine that for my case?

     

    My goal, is to render sales Territories over a map of the US.

     

    The territories each have their own Geography, some are large (several states), and some are only a few Countys. 

     

    Wednesday, August 11, 2010 4:10 PM
  • Actually that Tile approach would work perfectly for my State and County line data, displaying it as an option under my territory data.
    Wednesday, August 11, 2010 5:56 PM