{"id":724,"date":"2008-02-13T23:52:00","date_gmt":"2008-02-13T23:52:00","guid":{"rendered":"\/blogs\/bobb\/post\/Using-SQL-Server-2008-spatial-and-the-Virtual-Earth-map-control-1.aspx"},"modified":"2015-01-20T08:19:03","modified_gmt":"2015-01-20T16:19:03","slug":"using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/","title":{"rendered":"Using SQL Server 2008 spatial and the Virtual Earth map control &#8211; 1"},"content":{"rendered":"<p>\nLast week at the SQL Server 2008 Jumpstart I showed an example of using SQL Server 2008 spatial data types with Virtual Earth. I showed a single coding style. There really is a plethora of coding styles to using these together, and I&#39;d like to describe some of the most common ones. I&#39;d like to do this without much code for now, because an end-to-end description sometimes results in the graphic aspects (which other controls to use, how to build Ajax web pages, etc) seem to get in the way.\n<\/p>\n<p>\nI&#39;m not even going to mention using Virtual Earth to serve tiles directly, but only the Virtual Earth web control. Start with the Virtual Earth Interactive SDK for coding information.\n<\/p>\n<p>\nIn general, what we&#39;re after is:<br \/>\n&nbsp;&nbsp; Page contains Virtual Earth control<br \/>\n&nbsp;&nbsp; Page makes a request to a Web Service for data (usually Ajax)<br \/>\n&nbsp;&nbsp; Web Service get and processes data from database, returns data<br \/>\n&nbsp;&nbsp; Page uses Virtual Earth calls to present the data\n<\/p>\n<p>\nThe first two are straightforward, although the Virtual Earth control is available only online via a URL. This makes testing when you don&#39;t have internet access virtually impossible. The Ajax request (that is, call a URL with an XML payload using a browser-specific mechanism, wait asynchronously for the response) normally doesn&#39;t use SOAP-based Web Services, because you&#39;d have to add and remove the SOAP headers. It&#39;s usually XML-in, XML-out, sans SOAP headers.\n<\/p>\n<p>\nThe Virtual Earth calls depend on what version of Virtual Earth control you&#39;re using. I&#39;ll show this using version 6.<br \/>\n1. You can render using shapes directly<br \/>\n2. You can import GEORSS into a shape layer<br \/>\n3. You can import KML into a shape layer\n<\/p>\n<p>\nVirtual Earth supports visualizing shapes directly (#1 above) by using:<br \/>\n1. AddPushpin &#8211; to visualize a point or the centroid of a polygon<br \/>\n2. AddPolyline &#8211; that&#39;s Linestring in SQL Server 2008<br \/>\n3. AddPolygon &#8211; for polygons\n<\/p>\n<p>\nFor shape layers (#2 and #3 above), the code looks something like this:\n<\/p>\n<p>\nvar l = new VEShapeLayer();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>\nvar veLayerSpec = new VEShapeSourceSpecification(type, local.xml, l);\n<\/p>\n<p>\nmap.ImportShapeLayerData(veLayerSpec, onFeedLoad);\n<\/p>\n<p>\nThe &quot;type&quot; in the VEShapeSourceSpecification constructor can either be GEORSS or ImportXML (that&#39;s KML). You can also have a Live Search Maps Collection but likely that one won&#39;t come from SQL Server.&nbsp;&nbsp;Bear in mind that the VEShapeSourceSpecification constructor needs a *local* XML file URL. If you don&#39;t want to use a local XML file, you can build an ASP.NET HTTPHandler that uses redirection to pretend a remote XML file is local (see Mike McDougall&#39;s article and code to accomplish this).\n<\/p>\n<p>\nOne last twist that I&#39;ve seen is that you can build your Javascript code directly in each page OR make the Web Service program reformat your data into Javascript calls directly. Once you&#39;re back at the page (the Web Service passes back a string of Javascript) you simply call Javascript&#39;s &quot;eval&quot; function. This makes the web page client-side code easy, but the Web Service code lots more complex, as you&#39;re generating code, not points, lines, and polygons.\n<\/p>\n<p>\nWeb Service choices follow next&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week at the SQL Server 2008 Jumpstart I showed an example of using SQL Server 2008 spatial data types with Virtual Earth. I showed a single coding style. There really is a plethora of coding styles to using these together, and I&#39;d like to describe some of the most common ones. I&#39;d like to [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,36],"tags":[],"class_list":["post-724","post","type-post","status-publish","format-standard","hentry","category-sql-server-2008","category-sql-server-spatial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using SQL Server 2008 spatial and the Virtual Earth map control - 1 - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using SQL Server 2008 spatial and the Virtual Earth map control - 1 - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"Last week at the SQL Server 2008 Jumpstart I showed an example of using SQL Server 2008 spatial data types with Virtual Earth. I showed a single coding style. There really is a plethora of coding styles to using these together, and I&#039;d like to describe some of the most common ones. I&#039;d like to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2008-02-13T23:52:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-01-20T16:19:03+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/\",\"name\":\"Using SQL Server 2008 spatial and the Virtual Earth map control - 1 - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2008-02-13T23:52:00+00:00\",\"dateModified\":\"2015-01-20T16:19:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2008\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2008\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using SQL Server 2008 spatial and the Virtual Earth map control &#8211; 1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using SQL Server 2008 spatial and the Virtual Earth map control - 1 - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/","og_locale":"en_US","og_type":"article","og_title":"Using SQL Server 2008 spatial and the Virtual Earth map control - 1 - Bob Beauchemin","og_description":"Last week at the SQL Server 2008 Jumpstart I showed an example of using SQL Server 2008 spatial data types with Virtual Earth. I showed a single coding style. There really is a plethora of coding styles to using these together, and I&#39;d like to describe some of the most common ones. I&#39;d like to [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/","og_site_name":"Bob Beauchemin","article_published_time":"2008-02-13T23:52:00+00:00","article_modified_time":"2015-01-20T16:19:03+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/","name":"Using SQL Server 2008 spatial and the Virtual Earth map control - 1 - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2008-02-13T23:52:00+00:00","dateModified":"2015-01-20T16:19:03+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2008","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2008\/"},{"@type":"ListItem","position":3,"name":"Using SQL Server 2008 spatial and the Virtual Earth map control &#8211; 1"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=724"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/724\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}