Archive for the ‘Geo Spatial’ Category

Post

GEOCode an Address

In Bing Maps,Geo Spatial,Mapping on February 24, 2012 by mws580

Bing Control to Convert a Text Address into a Location

Add a Service Reference

From Visual Studio service reference point to http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex for the dev environment. There are staging and production links so you appropriate ones for your application.

Staging:

http://staging.dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc

Production:

http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc

http://msdn.microsoft.com/en-us/library/dd221354.aspx

GEOCode ServiceReference

Comments Off

Post

Found it, Lost it, Found it

In Bing Maps,Geo Spatial,Mapping on February 23, 2012 by mws580

Just when I became well versed in mapping with the bing map control and the ability to plot locations from SQL,  the come out wit an improved version that is totally different. 

My old code still works just fine when referencing the v6.2 library. 

Control on a diet.

To accommodate Mobile computing the control was slimmed down to its core.  As the developer needed other functionality they could add modules as needed to fulfill tasks.

Here is an article on importing GEORss feeds.

GEORSss and Bing Map v7

What’s new in Bing Map 7

Here is Keith Kinnan’s list of updates

What is new

Comments Off

Post

Add Map and Points to Windows Phone 7

In Bing Maps,Geo Spatial,Silverlight,SQL Saturday,Windows Phone 7 on January 15, 2011 by mws580

Here are the steps to add a map and point on the map.

1) Add a reference to Microsoft.Phone.Controls.Maps

2) Drag a ‘Map’ Windows Phone Control to the Page xaml.

3) Register on Bing Maps Portal and obtain an ID or Key.  Without this the map will display not register message.

4) Add the key obtained above to the xaml code.  Modify the xaml created by dragging the control and dropping it on the page.

    <Microsoft_Phone_Controls_Maps:Map    Name="map1" VerticalAlignment="Top" >     
            <Microsoft_Phone_Controls_Maps:Map.CredentialsProvider>
                <Microsoft_Phone_Controls_Maps:ApplicationIdCredentialsProvider ApplicationId="your key here" />
            </Microsoft_Phone_Controls_Maps:Map.CredentialsProvider>
    </Microsoft_Phone_Controls_Maps:Map>

 

5) Go to  the code behind

6) Add a using statement to reference the map control

using Microsoft.Phone.Controls.Maps;
using Microsoft.Phone.Controls.Maps.Platform;

7)  Add an instance variable for the page

MapLayer PinLayer1;

8) Create a pin and location

Pushpin MyPin = new Pushpin();
MyPin.Location = new Location();

9)  Set the Lat and Lon for the location.

MyPin.Location.Latitude = 27.96206353406851;
MyPin.Location.Longitude = -82.44960308074951;

10) Add a label to the Pin

MyPin.Content = "KForce";

11) Create a Map Layer

PinLayer1 = new MapLayer();

12) Add  Pin to Layer

PinLayer1.Children.Add(MyPin);

13) Add Layer to map

map1.Children.Add(PinLayer1);

14)  Center and Zoom on the location

map1.Center = MyPin.Location;
map1.ZoomLevel = 9;

Happy Coding

Comments Off

Post

Get Location on Windows Phone 7

In Geo Spatial,Mapping,SQL Saturday,Windows Phone 7 on January 15, 2011 by mws580

To get the geographic location of the device there ae a few steps to follow. 

1) Add a reference to System.Device

2) Add a ‘using’ line using System.Device.Location;

3) At the start of the page add a listener

GeoCoordinateWatcher watcher;

For a one time get of the location…

4) Add a button that calls the event defined here

private void StartLocationButton_Click(object sender, RoutedEventArgs e)
{
    // The watcher variable was previously declared as type GeoCoordinateWatcher.
    if (watcher == null)
    {
        watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // Use high accuracy.
        watcher.MovementThreshold = 20; // Use MovementThreshold to ignore noise in the signal.
        watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
    }
    watcher.Start();
}
5) Add the listening event that the above function calls.  It is listening for the status change.  The start above causes a status change.  Notice there is a stop at the end.  Geo Location service burns battery time.

void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
    if (e.Status == GeoPositionStatus.Ready)
    {
        // Use the Position property of the GeoCoordinateWatcher object to get the current location.
        GeoCoordinate co = watcher.Position.Location;
        latitudeTextBlock.Text = co.Latitude.ToString("0.000");
        longitudeTextBlock.Text = co.Longitude.ToString("0.000");
        //Stop the Location Service to conserve battery power.
        watcher.Stop();
    }
}

 

Happy Coding

Comments Off

t

There were great attendees to the SQL Saturday presentation “Spatial Queries in SQL 2008”

First, here are the slide,database , SQL, and ASP.Net code in one zip file.

Download from SQLSaturday website

Here are some links mentioned during the presentation.

1) Geocoding addresses using Google See sample on Codeplex.com

2) BING maps SDK AJAX version

3) Bing maps SDK Silverlight version

4) Window Mobile 7 toolkit Download the Tools

phone7

SQL Saturday 49 Orlando

on October 16, 2010 by mws580

Comments Off

t

Thank you all for attending my session here are the files to download and get stated with spatial data with SQL Server 2008 and Virtual Earth.

Everything (PPT,ASP.NET,Database)

Just the ASP.Net code

Just database backup

Just the script to build the database

Just the PowerPoint

Bing Maps AJAX SDK

Bing Maps Silverlight SDK

SQL Saturday Tampa – Spatial Data

on January 23, 2010 by mws580

Comments Off

t

As promised here are the slides from the presentation.

PowerPoint Slides

PDF version on the slides

Tampa Code Camp 2009

on November 7, 2009 by mws580

Comments Off

Post

Geography

In Geo Spatial,SQL Server 2008 on October 14, 2009 by mws580

IF OBJECT_ID ( 'dbo.SpatialTable', 'U' ) IS NOT NULL 
DROP TABLE dbo.SpatialTable; 
GO
CREATE TABLE SpatialTable 
( 
id int IDENTITY (1,1), 
GeogCol1 geography, 
GeogCol2 AS GeogCol1.STAsText() 
); 
GO 
INSERT INTO SpatialTable 
(GeogCol1)
VALUES 
(geography::STGeomFromText('LINESTRING(47.656 -122.360, 47.656 -122.343)', 4326)); 

INSERT INTO SpatialTable 
(GeogCol1) 
VALUES 
(geography::STGeomFromText('POLYGON((47.653 -122.358, 47.649 -122.348, 
47.658 -122.348, 47.658 -122.358, 47.653 -122.358))', 4326)); 
GO

Comments Off

Follow

Get every new post delivered to your Inbox.