- bingwebpartproject.zip
- BingWebPartProject
- BingWebPartProject.sln
- BingWebPartProject.suo
- BingWebPartProject
- app.config
- bin
- Debug
- Release
- BingMapHelper.cs
- BingMapsWebPart
- BingWebPartProject.csproj
- BingWebPartProject.csproj.user
- ControlTemplates
- BingWebPartProject
- SharePointProjectItem.spdata
- Features
- Feature1
- key.snk
- Package
- pkg
- Debug
- VisualWebPartProject1
- ControlTemplates
- VisualWebPartProject1
- manifest.xml
- VisualWebPartProject1.dll
- VisualWebPartProject1_Feature1
- BingMapsWebPart
- Feature.xml
- SimpleOOBListManip
- VisualWebPart1
- pkgobj
- Debug
- Properties
- Service References
- GeocodeService
- ImageryService
- VisualWebPartProject1.suo
|
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VisualWebPartProject1.GeocodeService;
using VisualWebPartProject1.ImageryService;
using VisualWebPartProject1.ControlTemplates;
namespace VisualWebPartProject1.BingMapsWebPart
{
public partial class BingMapsWebPartUserControl : UserControl
{
const string longititudeKey = "longititude";
const string latitudeKey = "latitude";
const string zoomKey = "zoom";
double longititude;
double latitude;
int zoom = 15;
protected void Page_Load(object sender, EventArgs e)
{
lblError.Visible = true;
if (ViewState[longititudeKey] != null)
{
longititude = (double)ViewState[longititudeKey];
latitude = (double)ViewState[latitudeKey];
zoom = (int)ViewState[zoomKey];
}
//if (!Page.IsPostBack)
{
((BingMapNav)BingMapNav1).ZoomOutButtonClick += new BingMapNav.ButtonClickDelegate(ZoomOut);
((BingMapNav)BingMapNav1).ZoomInButtonClick += new BingMapNav.ButtonClickDelegate(ZoomIn);
((BingMapNav)BingMapNav1).ScrollDownButtonClick += new BingMapNav.ButtonClickDelegate(ScrollDown);
((BingMapNav)BingMapNav1).ScrollLeftButtonClick += new BingMapNav.ButtonClickDelegate(ScrollLeft);
((BingMapNav)BingMapNav1).ScrollRightButtonClick += new BingMapNav.ButtonClickDelegate(ScrollRight);
((BingMapNav)BingMapNav1).ScrollUpButtonClick += new BingMapNav.ButtonClickDelegate(ScrollUp);
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState[longititudeKey] = longititude;
ViewState[latitudeKey] = latitude;
ViewState[zoomKey] = zoom;
}
protected void ZoomOut()
{
zoom -=2;
lblError.Text = "New Zoom " + zoom;
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
}
protected void ZoomIn()
{
zoom += 2;
lblError.Text = "New Zoom " + zoom;
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
}
protected void ScrollDown()
{
latitude -= 0.2;
lblError.Text = "New latitude " + latitude;
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
}
protected void ScrollLeft()
{
longititude -= 0.2;
lblError.Text = "New longititude " + longititude;
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
}
protected void ScrollRight()
{
longititude += 0.2;
lblError.Text = "New longititude " + longititude;
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
}
protected void ScrollUp()
{
latitude += 0.2;
lblError.Text = "New latitude " + latitude;
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
}
protected void btnGetMap_Click(object sender, EventArgs e)
{
lblError.Visible = false;
try
{
//Get map
GeocodeResponse resp = BingMapHelper.GeocodeAddressGeocodeResponse(txtAddress.Text);
latitude = resp.Results[0].Locations[0].Latitude;
longititude = resp.Results[0].Locations[0].Longitude;
//Get URI and set image
mapImage.ImageUrl = BingMapHelper.GetImagery(latitude, longititude, zoom);
//Show image
mapImage.Visible = true;
}
catch (Exception ex)
{
lblError.Visible = true;
lblError.Text = ex.Message + "<BR>" + ex.StackTrace;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.