Hi all ,I am doing a window phone 7 GPS application for my final year project. I needed help on how to put the red symbols on to the map of my GPS location to pinpoint my current location once I execute the GPS through a button.Here are my codes , please help me to modify it:
MainPage1.xaml:
<!--TitlePanel contains the name of the application and page title-->
<esri:Map Grid.Row="1" Margin="12,27,0,85" Name="MyMap" MouseLeftButtonUp="image_MouseLeftButtonUp" MapGesture="MyMap_MapGesture">
<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://www.onemap.sg/ArcGIS/rest/services/basemap/MapServer" />
<esriDS:GpsLayer x:Name="myGpsLayer" />
<esri:GraphicsLayer ID="MyGraphicsLayer" >
<esri:GraphicsLayer.Graphics>
<!-- Strobe symbol -->
<esri:Graphic Symbol="{StaticResource StrobeMarkerSymbol}">
<!--For direction X ,Y-->
<esriGeometry:MapPoint X="100" Y="400" >
<esriGeometry:Geometry.SpatialReference>
<esriGeometry:SpatialReference WKID="4326" />
</esriGeometry:Geometry.SpatialReference>
</esriGeometry:MapPoint>
</esri:Graphic>
</esri:GraphicsLayer.Graphics>
</esri:GraphicsLayer>
</esri:Map>
MainPage1.cs
//This the button that execute the GPS function
private void gpsButton_Click(object sender, RoutedEventArgs e)
{
if (watcher == null)
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 20;
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordi nate>>(watcher_PositionChanged);
watcher.Start();
}
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => MyPositionChanged(e));
}
void MyPositionChanged(GeoPositionChangedEventArgs<GeoC oordinate> e)
{
double posx = double.Parse(e.Position.Location.Latitude.ToString ("0.000"));
double posy = double.Parse(e.Position.Location.Longitude.ToStrin g("0.000"));
//LatitudeTextBlock.Text = e.Position.Location.Latitude.ToString("0.000");
// LongitudeTextBlock.Text = e.Position.Location.Longitude.ToString("0.000");
}
private void GraphicsLayer_MouseLeftButtonDown(object sender, ESRI.ArcGIS.Client.GraphicMouseButtonEventArgs e)
{
if (e.Graphic.Selected)
e.Graphic.UnSelect();
else
e.Graphic.Select();
}




LinkBack URL
About LinkBacks






Reply With Quote

