本文整理汇总了C#中MapOverlay类的典型用法代码示例。如果您正苦于以下问题:C# MapOverlay类的具体用法?C# MapOverlay怎么用?C# MapOverlay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapOverlay类属于命名空间,在下文中一共展示了MapOverlay类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: showlocations
private void showlocations()
{
foreach (Place p in _vm.Places)
{
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
BitmapImage bmi = new BitmapImage(new Uri("/Assets/pushpinPhone.png", UriKind.Relative));
Image img = new Image();
img.Tag = (p);
img.Source = bmi;
MyGrid.Children.Add(img);
//Creating a MapOverlay and adding the Grid to it.
MapOverlay MyOverlay = new MapOverlay();
MyOverlay.Content = MyGrid;
MyOverlay.GeoCoordinate = new GeoCoordinate(p.Latitude, p.Longitude);
MyOverlay.PositionOrigin = new Point(0, 0.5);
//Creating a MapLayer and adding the MapOverlay to it
MapLayer MyLayer = new MapLayer();
MyLayer.Add(MyOverlay);
mapWithMyLocation.Layers.Add(MyLayer);
}
}
开发者ID:landerarnoys,项目名称:Shredder,代码行数:33,代码来源:MainPage.xaml.cs
示例2: AddMapIcon
private void AddMapIcon(Map map, GeoCoordinate geoPosition)
{
// Create a small circle to mark the current location.
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Blue);
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
// Create a MapOverlay to contain the circle.
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geoPosition;
// Create a MapLayer to contain the MapOverlay.
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
// Add the MapLayer to the Map.
maploc.Layers.Add(myLocationLayer);
}
开发者ID:AegeanApp,项目名称:Aegean-App-V1,代码行数:26,代码来源:MapsPage.xaml.cs
示例3: ShowMyLocationOnTheMap
private async void ShowMyLocationOnTheMap()
{
// Get my current location.
Geolocator myGeolocator = new Geolocator();
Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);
// Make my current location the center of the Map.
this.mapWithMyLocation.Center = myGeoCoordinate;
this.mapWithMyLocation.ZoomLevel = 13;
// Create a small circle to mark the current location.
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Red);
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
// Create a MapOverlay to contain the circle.
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = myGeoCoordinate;
// Create a MapLayer to contain the MapOverlay.
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
// Add the MapLayer to the Map.
mapWithMyLocation.Layers.Add(myLocationLayer);
txTop.Text = ("My Location - Lat " + myGeoCoordinate.Latitude.ToString("0.0000") + " Lon " + myGeoCoordinate.Longitude.ToString("0.0000"));
}
开发者ID:alexpt2000,项目名称:CompassV1,代码行数:34,代码来源:Map.xaml.cs
示例4: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string quakeQueryString = string.Empty;
if (NavigationContext.QueryString.TryGetValue("quake", out quakeQueryString))
{
quake = Earthquake.DeserializeFromQueryString(quakeQueryString);
}
else return;
ContentPanel.DataContext = quake;
QuakeMap.Center = quake.Location;
Pushpin pin = new Pushpin
{
GeoCoordinate = quake.Location,
Content = quake.FormattedMagnitude
};
if (quake.Magnitude >= appSettings.MinimumWarningMagnitudeSetting)
pin.Background = Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
MapOverlay overlay = new MapOverlay();
overlay.Content = pin;
overlay.GeoCoordinate = quake.Location;
overlay.PositionOrigin = new Point(0, 1);
MapLayer layer = new MapLayer();
layer.Add(overlay);
QuakeMap.Layers.Add(layer);
base.OnNavigatedTo(e);
}
开发者ID:adamsp,项目名称:wsnz-windowsphone,代码行数:32,代码来源:QuakeDisplayPage.xaml.cs
示例5: ShowMyLocationOnTheMap
private async void ShowMyLocationOnTheMap()
{
// Get my current location.
Geolocator myGeolocator = new Geolocator();
Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);
// Create a small circle to mark the current location.
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Blue);
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
// Create a MapOverlay to contain the circle.
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = myGeoCoordinate;
// Create a MapLayer to contain the MapOverlay.
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
// Add the MapLayer to the Map.
Haritam.Layers.Add(myLocationLayer);
}
开发者ID:ramazanguclu,项目名称:EnUcuzUrun,代码行数:28,代码来源:Harita.xaml.cs
示例6: DrawPoint
public void DrawPoint(Map map, GeoCoordinate position, Color color, BitmapImage picture = null, int sizeInd = 0)
{
var border = new Border()
{
CornerRadius = new CornerRadius(50),
Width = 30 + sizeInd * 10,
Height = 30 + sizeInd * 10,
BorderThickness = new Thickness(5),
BorderBrush = new SolidColorBrush(color),
Background = new SolidColorBrush(color)
};
if (picture != null)
border.Child = new Image() { Source = picture };
var myOverlay = new MapOverlay()
{
Content = border,
GeoCoordinate = position,
PositionOrigin = new Point(0, 0.5)
};
MapLayer.Add(myOverlay);
if (map.Layers.Count == 0)
map.Layers.Add(MapLayer);
}
开发者ID:Noitacinrofilac,项目名称:Who-s-Hungry,代码行数:27,代码来源:MapDrawingModel.cs
示例7: App_PositionUpdated
void App_PositionUpdated(object sender, EventArgs e)
{
Dispatcher.BeginInvoke(() =>
{
ForeLocationCount++;
if(oneMarker == null){
oneMarker = new MapOverlay();
MapLayer oneMarkerLayer = new MapLayer();
Ellipse Circhegraphic = new Ellipse();
Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow);
Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
Circhegraphic.StrokeThickness = 10;
Circhegraphic.Opacity = 0.8;
Circhegraphic.Height = 30;
Circhegraphic.Width = 30;
oneMarker.Content = Circhegraphic;
oneMarker.PositionOrigin = new Point(0.5, 0.5);
oneMarkerLayer.Add(oneMarker);
map1.Layers.Add(oneMarkerLayer);
}
oneMarker.GeoCoordinate = App.lastLocation;
if (!App.RunningInBackground)
{
map1.Center = oneMarker.GeoCoordinate;
}
statusBox.Text = "Count :" + ForeLocationCount + "/"+ App.GottenLocationsCunt + ", sess: " + App.RunningInBackgroundCunt;
});
}
开发者ID:ZeynepCamurdan,项目名称:maps-samples,代码行数:35,代码来源:MainPage.xaml.cs
示例8: webClient_DownloadStringCompleted
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var rootObject = JsonConvert.DeserializeObject<Rootobject>(e.Result);
double lat, longitude;
MapPolyline line = new MapPolyline();
line.StrokeColor = Colors.Green;
line.StrokeThickness = 2;
double[] coord = new double[2 * rootObject.direction[0].stop.Length];
for (int i = 0; i < rootObject.direction[0].stop.Length; i++)
{
lat = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lat);
longitude = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lon);
line.Path.Add(new GeoCoordinate(lat, longitude));
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Green);
myCircle.Height = 15;
myCircle.Width = 15;
myCircle.Opacity = 60;
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = new GeoCoordinate(lat, longitude, 200);
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
map.Layers.Add(myLocationLayer);
}
map.MapElements.Add(line);
}
开发者ID:huyle333,项目名称:windowsapp2013,代码行数:31,代码来源:GreenLine.xaml.cs
示例9: AddPinOnMap
private void AddPinOnMap()
{
geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].longitude));
geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].longitude));
Image pinIMG = new Image();
pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_green.png", UriKind.Relative));
pinIMG.Width = 50;
pinIMG.Height = 50;
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = pinIMG;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geo1;
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
mapJourney.Layers.Add(myLocationLayer);
myLocationLayer = null;
myLocationOverlay = null;
pinIMG = null;
pinIMG = new Image();
pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_red.png", UriKind.Relative));
pinIMG.Width = 50;
pinIMG.Height = 50;
myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = pinIMG;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geo2;
myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
mapJourney.Layers.Add(myLocationLayer);
myLocationLayer = null;
myLocationOverlay = null;
pinIMG = null;
mapJourney.ZoomLevel = ZoomLevel;
mapJourney.Center = geo2;
}
开发者ID:kushalSengupta,项目名称:AgeasDriver,代码行数:35,代码来源:FrmMap.xaml.cs
示例10: ShowMyLocationOnTheMap
private async void ShowMyLocationOnTheMap()
{
Geolocator myGeolocator = new Geolocator();
Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);
this.BettingMap.Center = myGeoCoordinate;
this.BettingMap.ZoomLevel = 15;
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Blue);
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = myGeoCoordinate;
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
BettingMap.Layers.Add(myLocationLayer);
}
开发者ID:vlatkooo,项目名称:MyTicket,代码行数:26,代码来源:MainPage.xaml.cs
示例11: addLocationToMap
private void addLocationToMap()
{
myMap = map;
GeoCoordinate myGeocoordinate = new GeoCoordinate(latitude, longitude);
myMap.Center = myGeocoordinate;
myMap.ZoomLevel = 14;
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Red);
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0, 1);
myLocationOverlay.GeoCoordinate = myGeocoordinate;
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
myMap.Layers.Add(myLocationLayer);
}
开发者ID:Boonstra,项目名称:getConnected-WP8,代码行数:25,代码来源:MapPage.xaml.cs
示例12: AddPoint
private void AddPoint(Map controlMap, GeoCoordinate geo)
{
// With the new Map control:
// Map -> MapLayer -> MapOverlay -> UIElements
// - Add a MapLayer to the Map
// - Add an MapOverlay to that layer
// - We can add a single UIElement to that MapOverlay.Content
MapLayer ml = new MapLayer();
MapOverlay mo = new MapOverlay();
// Add an Ellipse UI
Ellipse r = new Ellipse();
r.Fill = new SolidColorBrush(Color.FromArgb(255, 240, 5, 5));
// the item is placed on the map at the top left corner so
// in order to center it, we change the margin to a negative
// margin equal to half the width and height
r.Width = r.Height = 12;
r.Margin = new Thickness(-6, -6, 0, 0);
// Add the Ellipse to the Content
mo.Content = r;
// Set the GeoCoordinate of that content
mo.GeoCoordinate = geo;
// Add the MapOverlay to the MapLayer
ml.Add(mo);
// Add the MapLayer to the Map
controlMap.Layers.Add(ml);
}
开发者ID:natsirt20,项目名称:School,代码行数:28,代码来源:Geolocation.xaml.cs
示例13: InitApartments
private async void InitApartments()
{
var apartments = await App.MobileService.GetTable<Apartment>().Where(a => a.Published == true).ToListAsync();
listApartments.ItemsSource = apartments;
mapApartments.Layers.Clear();
MapLayer layer = new MapLayer();
foreach (Apartment apartment in apartments)
{
MapOverlay overlay = new MapOverlay();
overlay.GeoCoordinate = new GeoCoordinate(apartment.Latitude, apartment.Longitude);
overlay.PositionOrigin = new Point(0, 0);
Grid grid = new Grid { Height = 40, Width = 25, Background = new SolidColorBrush(Colors.Red) };
TextBlock text = new TextBlock { Text = apartment.Bedrooms.ToString(), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
grid.Children.Add(text);
overlay.Content = grid;
grid.Tap += (s, e) =>
{
MessageBox.Show(
"Address: " + apartment.Address + Environment.NewLine + apartment.Bedrooms + " bedrooms",
"Apartment", MessageBoxButton.OK);
mapApartments.SetView(overlay.GeoCoordinate, 15, MapAnimationKind.Parabolic);
};
layer.Add(overlay);
}
mapApartments.Layers.Add(layer);
}
开发者ID:NoamSheffer,项目名称:rentahome,代码行数:27,代码来源:MainPage.xaml.cs
示例14: Seanslar_getCompleted
void Seanslar_getCompleted(seanslar sender)
{
loader.IsIndeterminate = false;
PanoramaRoot.Title = sender.SalonBilgisi.name;
pItem1.DataContext = sender.SalonBilgisi;
listFilmler.ItemsSource = sender.SalonBilgisi.movies;
if (sender.SalonBilgisi.latitude.ToString() != "false")
{
SalonCoordinate = new GeoCoordinate(double.Parse(sender.SalonBilgisi.latitude), double.Parse(sender.SalonBilgisi.longitude));
myMap.SetView(SalonCoordinate, 17);
pinpoint_salon newPin = new pinpoint_salon();
MapOverlay newOverlay = new MapOverlay();
newOverlay.Content = newPin;
newOverlay.GeoCoordinate = SalonCoordinate;
newOverlay.PositionOrigin = new Point(0, 0);
MapLayer MyLayer = new MapLayer();
MyLayer.Add(newOverlay);
myMap.Layers.Add(MyLayer);
}
else
{
myMap.Visibility = Visibility.Collapsed;
recMap.Visibility = System.Windows.Visibility.Collapsed;
}
}
开发者ID:yajinn,项目名称:sinemaciWP,代码行数:29,代码来源:SalonPage.xaml.cs
示例15: CustomPushPinWithToolTip
public CustomPushPinWithToolTip(HeritageProperty item, MapOverlay overlay)
{
this.ParentOverlay = overlay;
this.Item = item;
this.Description = item.Name;
InitializeComponent();
Loaded += UCCustomToolTip_Loaded;
}
开发者ID:RhysPartlett,项目名称:oakville-heritage-properties,代码行数:8,代码来源:CustomPushPinWithToolTip.xaml.cs
示例16: detail
public detail()
{
InitializeComponent();
List<Stand> tab = (List<Stand>)PhoneApplicationService.Current.State["stands"];
int index = (int)PhoneApplicationService.Current.State["index"];
//MessageBox.Show(index.ToString());
Stand item = tab[index];
station_id.Text = "Station n°" + item.Id;
add.Text = item.Add.ToString();
ab.Text = "Places : " + item.Ab.ToString();
ap.Text = "Velos : " + item.Ap.ToString();
ac.Text = "Capacité disponible : " + item.Ac.ToString();
tc.Text = "Capacité totale: : " + item.Tc.ToString();
GeoCoordinate loc = new GeoCoordinate();
//Location loc = new Location();
loc.Longitude = item.Lng;
loc.Latitude = item.Lat;
Map Carte = new Map();
Carte.Center = loc;
Carte.ZoomLevel = 17.0;
Pushpin pin = new Pushpin();
pin.GeoCoordinate = loc;
//pin.Location = loc;
ContentMap.Children.Add(Carte);
ImageBrush imgBrush = new ImageBrush();
imgBrush.Stretch = System.Windows.Media.Stretch.UniformToFill;
imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
Rectangle MyRectangle = new Rectangle();
MyRectangle.Fill = imgBrush;
MyRectangle.Height = 52;
MyRectangle.Width = 85;
MyRectangle.SetValue(Grid.RowProperty, 0);
MyRectangle.SetValue(Grid.ColumnProperty, 0);
MyGrid.Children.Add(MyRectangle);
MapLayer layer = new MapLayer();
MapOverlay overlay = new MapOverlay();
overlay.GeoCoordinate = pin.GeoCoordinate;
overlay.Content = MyGrid;
layer.Add(overlay);
//Carte.Children.Add(pin);
Carte.Layers.Add(layer);
}
开发者ID:CSemmezies,项目名称:TP--WPF-Velo-Bleu,代码行数:57,代码来源:detail.xaml.cs
示例17: DrawRoute
void DrawRoute(RunData item)
{
JustRunDataContext db = new JustRunDataContext(JustRunDataContext.ConnectionString);
GeoCoordinateCollection geoCollection = new GeoCoordinateCollection();
var geoCords = db.GeoCords.Where(p => p.No == item.No);
foreach(var gc in geoCords)
{
GeoCoordinate _geoCord=new GeoCoordinate();
_geoCord.Longitude=gc.Longitude;
_geoCord.Latitude=gc.Latitude;
geoCollection.Add(_geoCord);
}
if (geoCollection.Count != 0)
Map.Center = geoCollection[0];
else
{
MessageBox.Show(AppResources.NoGeoFoundMsg);
NavigationService.GoBack();
return;
}
Map.ZoomLevel = 16;
Time.Text = item.Datetime.ToShortTimeString();
Date.Text = item.Datetime.ToShortDateString();
foreach (var geoCord in geoCollection)
{
_line.Path.Add(geoCord);
}
MapOverlay myLocationOverlay = new MapOverlay();
BitmapImage tn = new BitmapImage();
tn.SetSource(Application.GetResourceStream(new Uri(@"Assets/finishflag.png", UriKind.Relative)).Stream);
Image img = new Image();
img.Source = tn;
img.Height = 80;
img.Width = 80;
myLocationOverlay.Content = img;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geoCollection[geoCollection.Count - 1];
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
myLocationOverlay = new MapOverlay();
tn = new BitmapImage();
tn.SetSource(Application.GetResourceStream(new Uri(@"Assets/GreenBall.png", UriKind.Relative)).Stream);
img = new Image();
img.Source = tn;
img.Height = 25;
img.Width = 25;
myLocationOverlay.Content = img;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = geoCollection[0];
myLocationLayer.Add(myLocationOverlay);
Map.Layers.Add(myLocationLayer);
Map.Center = geoCollection[geoCollection.Count / 2];
}
开发者ID:flysofast,项目名称:Just-run---Windows-Phone,代码行数:56,代码来源:PrevRun.xaml.cs
示例18: PinCurrentPosition
private void PinCurrentPosition()
{
var currentPosition = new GeoCoordinate(App.ViewModel.CurrentPosition.Latitude, App.ViewModel.CurrentPosition.Longitude);
marker = new UserLocationMarker() { GeoCoordinate = currentPosition };
mapOverlay = new MapOverlay() { Content = this.marker, GeoCoordinate = currentPosition };
var mapLayer = new MapLayer { this.mapOverlay };
MyMap.Layers.Add(mapLayer);
}
开发者ID:NPadrutt,项目名称:Places,代码行数:10,代码来源:MapView.xaml.cs
示例19: SetItemsCollection
public static NotifyCollectionChangedEventHandler SetItemsCollection(this MapLayer layer, INotifyCollectionChanged collection, DataTemplate template)
{
if (collection == null) return null;
Action<IList> RemoveMapOverlays = (items) =>
{
if (items == null || items.Count == 0) return;
for (int i = layer.Count - 1; i >= 0; i--)
if (items.Contains(layer[i].Content))
layer.RemoveAt(i);
};
Action<IList> CreateMapOverlays = (items) =>
{
if (items == null || items.Count == 0) return;
foreach (var item in items)
{
var overlay = new MapOverlay();
var coord = item as IHasCoordinate;
overlay.ContentTemplate = template;
overlay.Content = item;
overlay.GeoCoordinate = coord.Coordinate;
overlay.PositionOrigin = new System.Windows.Point(0.5, 1);
layer.Add(overlay);
}
};
NotifyCollectionChangedEventHandler ItemsChanged = (sender, e) =>
{
switch (e.Action)
{
case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
CreateMapOverlays(e.NewItems);
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
RemoveMapOverlays(e.OldItems);
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
RemoveMapOverlays(e.OldItems);
CreateMapOverlays(e.NewItems);
break;
case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
layer.Clear();
CreateMapOverlays(collection as IList);
break;
default:
break;
}
};
collection.CollectionChanged += ItemsChanged;
return ItemsChanged;
}
开发者ID:Lee-Nover,项目名称:PublicBikes,代码行数:55,代码来源:MapExtensions.cs
示例20: map1_MouseLeftButtonUp
void map1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Debug.WriteLine("map_MouseLeftButtonUp " + markerSelected + ", addPoint: " + addPoint);
if (addPoint)
{
if (markerLayer == null) // create layer if it does not exists yet
{
markerLayer = new MapLayer();
map1.Layers.Add(markerLayer);
}
MarkerCounter++;
MapOverlay oneMarker = new MapOverlay();
oneMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1));
Ellipse Circhegraphic = new Ellipse();
Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow);
Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
Circhegraphic.StrokeThickness = 10;
Circhegraphic.Opacity = 0.8;
Circhegraphic.Height = 30;
Circhegraphic.Width = 30;
oneMarker.Content = Circhegraphic;
oneMarker.PositionOrigin = new Point(0.5, 0.5);
Circhegraphic.MouseLeftButtonDown += Circhegraphic_MouseLeftButtonDown;
Circhegraphic.MouseLeftButtonUp += Circhegraphic_MouseLeftButtonUp;
markerLayer.Add(oneMarker);
if (dynamicPolyline == null) // create polyline if it does not exists yet
{
dynamicPolyline = new MapPolyline();
dynamicPolyline.StrokeColor = Color.FromArgb(0x80, 0xFF, 0x00, 0x00);
dynamicPolyline.StrokeThickness = 5;
dynamicPolyline.Path = new GeoCoordinateCollection() {
map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1))
};
map1.MapElements.Add(dynamicPolyline);
}
else // just add points to polyline here
{
dynamicPolyline.Path.Add(map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1)));
}
}
addPoint = false;
markerSelected = false;
}
开发者ID:ZubaerNaseem,项目名称:maps-samples,代码行数:55,代码来源:MainPage.xaml.cs
注:本文中的MapOverlay类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论