本文整理汇总了C#中MapLayer.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# MapLayer.AddChild方法的具体用法?C# MapLayer.AddChild怎么用?C# MapLayer.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapLayer
的用法示例。
在下文中一共展示了MapLayer.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectDestination
public SelectDestination()
{
InitializeComponent();
street.Visibility = Visibility.Visible;
(ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true;
GeoCoordinate geo = new GeoCoordinate();
geo = MainPage.bookingData.current_location;
googlemap.Center = geo;
googlemap.ZoomLevel = 16;
zzoom.IsEnabled = true;
positionLoaded = true;
Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
new_pushpin.Location = geo;
pushPinCurrentLocation = new MapLayer();
new_pushpin.Content = "Current Location:\n ";
new_pushpin.Content += MainPage.bookingData.current_location_address;
new_pushpin.Visibility = Visibility.Visible;
googlemap.Children.Add(pushPinCurrentLocation);
pushPinCurrentLocation.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);
if (MainPage.bookingData.isDesSet == true)
{
AddressMapping();
}
}
示例2: AddImagePushPin
private static void AddImagePushPin(string urlicon, double latitude, double longitude, string url, MapLayer layer)
{
Pin photoPin = new Pin
{
ImageSource = new BitmapImage(new Uri(urlicon, UriKind.RelativeOrAbsolute)),
MapInstance = (Map)layer.ParentMap
};
ToolTip tt = AddToolTip(new Image { Source = new BitmapImage(new Uri(url)) });
ToolTipService.SetToolTip(photoPin, tt);
layer.AddChild(photoPin, new Location(latitude, longitude, 0), PositionOrigin.Center);
}
示例3: VenuePage
public VenuePage()
{
InitializeComponent();
imageLayer = new MapLayer();
mapArea.Children.Add(imageLayer);
mapArea.Center = new GeoCoordinate(49.879738, -97.203598);
Image pinImage = new Image();
pinImage.Source = new BitmapImage(new Uri("images/prairiedevconpin.png", UriKind.Relative));
pinImage.Stretch = Stretch.None;
PositionOrigin origin = PositionOrigin.BottomCenter;
imageLayer.AddChild(pinImage, mapArea.Center, origin);
}
示例4: draw
public void draw(Map map)
{
MapLayer imageLayer = new MapLayer();
Image image = new Image();
image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("movie.png", UriKind.Relative));
image.Opacity = 0.8;
image.Stretch = System.Windows.Media.Stretch.None;
image.MouseLeftButtonDown += new MouseButtonEventHandler(image_MouseLeftButtonDown);
PositionOrigin position = PositionOrigin.Center;
imageLayer.AddChild(image, location, position);
map.Children.Add(imageLayer);
ref_mainMap = map;
}
示例5: AddLocation
private void AddLocation()
{
MapLayer imageLayer = new MapLayer();
VenueViewModel venue = DataContext as VenueViewModel;
Image image = new Image();
//Define the URI location of the image
image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(venue.Icon, UriKind.Absolute));
//Define the image display properties
image.Opacity = 0.8;
image.Stretch = System.Windows.Media.Stretch.None;
//Add the image to the defined map layer
imageLayer.AddChild(image, venue.Location, PositionOrigin.Center);
//Add the image layer to the map
map.Children.Add(imageLayer);
}
示例6: PlaceEvent
public PlaceEvent()
{
InitializeComponent();
myMap.Focus();
//Create custom pin for the users location
Image userLocationPin = new Image();
userLocationPin.Source = new BitmapImage(new Uri("images/userPin.png", UriKind.Relative));
ToolTipService.SetToolTip(userLocationPin, "You are here");
userLocationPin.Width = 20;
userLocationPin.Height = 20;
GeoLookup myGeoLookup = new GeoLookup();
// Get host IP Address
string myIP = new System.Net.WebClient().DownloadString("http://ipinfo.io/ip");
// Turn IP Address into geo location lat & long
myGeoLookup.GetGeo(myIP);
// Right click to add pin method call
myMap.MouseRightButtonDown += new MouseButtonEventHandler(Click_AddPins);
//Wait for page load
Loaded += onLoad;
// users current position on map
myMap.Center = new Location(Convert.ToDouble(myGeoLookup.Latitude), Convert.ToDouble(myGeoLookup.Longitude));
//myMap.Center = new Location(52.792542056467, -6.14546695770263);
// Map default zoom level 0-20
myMap.ZoomLevel = 15;
// Create new layer to hold pins
MapLayer pinLayer = new MapLayer();
//User Pin
pinLayer.AddChild(userLocationPin, myMap.Center, PositionOrigin.Center);
// Add pinlayer on top of maplayer
myMap.Children.Add(pinLayer);
}
示例7: btn_Map_Click
private void btn_Map_Click(object sender, RoutedEventArgs e)
{
sp_Map.Visibility = Visibility.Visible;
sp_Content.Visibility = Visibility.Collapsed;
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
watcher.Start();
map.SetView(watcher.Position.Location, 14);
map.Mode = new AerialMode();
Pin_My = new Image();
Pin_My = new Image() { Source = new BitmapImage(new Uri("/Image_Acquirer/man.png", UriKind.Relative)) };
Pin_My.Width = 40;
Pin_My.Height = 50;
layer = new MapLayer();
map.Children.Add(layer);
layer.AddChild(Pin_My, watcher.Position.Location);
Pin_My.Tag = watcher.Position.Location;
map.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(map_Tap);
}
示例8: draw
public void draw(Map map){
MapLayer imageLayer = new MapLayer();
Image image = new Image();
Uri uri = new Uri(this.URL);
image.Source = new System.Windows.Media.Imaging.BitmapImage(uri);
//Define the image display properties
image.Opacity = 0.8;
image.Stretch = System.Windows.Media.Stretch.None;
//Center the image around the location specified
PositionOrigin position = PositionOrigin.Center;
//Add the image to the defined map layer
imageLayer.AddChild(image, location, position);
//Add the image layer to the map
map.Children.Add(imageLayer);
}
示例9: AddLocations
private void AddLocations()
{
MapLayer imageLayer = new MapLayer();
foreach (CategoryViewModel category in App.ViewModel.Categories) {
if (category.Venues == null) continue;
foreach (VenueViewModel venue in category.Venues) {
Image image = new Image();
//Define the URI location of the image
image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(venue.Icon, UriKind.Absolute));
//Define the image display properties
image.Opacity = 0.8;
image.Stretch = System.Windows.Media.Stretch.None;
//Add the image to the defined map layer
imageLayer.AddChild(image, venue.Location, PositionOrigin.Center);
//Add the image layer to the map
}
}
Map.Children.Add(imageLayer);
}
示例10: addImageToMap
private void addImageToMap(object sender, RoutedEventArgs e)
{
MapLayer imageLayer = new MapLayer();
Image image = new Image();
image.Height = 150;
//Define the URI location of the image
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri("http://upload.wikimedia.org/wikipedia/commons/d/d4/Golden_Gate_Bridge10.JPG");
// To save significant application memory, set the DecodePixelWidth or
// DecodePixelHeight of the BitmapImage value of the image source to the desired
// height or width of the rendered image. If you don't do this, the application will
// cache the image as though it were rendered as its normal size rather then just
// the size that is displayed.
// Note: In order to preserve aspect ratio, set DecodePixelWidth
// or DecodePixelHeight but not both.
//Define the image display properties
myBitmapImage.DecodePixelHeight = 150;
myBitmapImage.EndInit();
image.Source = myBitmapImage;
image.Opacity = 0.6;
image.Stretch = System.Windows.Media.Stretch.None;
//The map location to place the image at
Location location = new Location() { Latitude = 37.8197222222222, Longitude = -122.478611111111 };
//Center the image around the location specified
PositionOrigin position = PositionOrigin.Center;
//Add the image to the defined map layer
imageLayer.AddChild(image, location, position);
//Add the image layer to the map
MapTileOverlay.Children.Add(imageLayer);
}
示例11: Locate_Click
private async void Locate_Click(object sender, EventArgs e)
{
positionLoaded = false;
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 10;
try
{
gPos = await geolocator.GetGeopositionAsync(
maximumAge: TimeSpan.FromSeconds(5),
timeout: TimeSpan.FromSeconds(10)
);
dlat = gPos.Coordinate.Latitude;
dlong = gPos.Coordinate.Longitude;
LatitudeTextBlock.Text = "Latitude: " + gPos.Coordinate.Latitude.ToString("0.000000"); //geoposition.Coordinate.Latitude.ToString("0.00"); //
LongitudeTextBlock.Text = "Longitude: " + gPos.Coordinate.Longitude.ToString("0.000000");//geoposition.Coordinate.Longitude.ToString("0.00"); //
//Storing in static variables for access in other pages of app
Booking.DestinationLat = gPos.Coordinate.Latitude.ToString("0.000000");
Booking.DestinationLong = gPos.Coordinate.Longitude.ToString("0.000000");
ReverseGeocodeQuery getAddress = new ReverseGeocodeQuery();
GeoCoordinate geo = new GeoCoordinate();
geo.Latitude = gPos.Coordinate.Latitude;
geo.Longitude = gPos.Coordinate.Longitude;
googlemap.Center = geo;
googlemap.ZoomLevel = 16;
string url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + geo.Latitude + "," + geo.Longitude + "&sensor=true";
var client = new WebClient();
string response = await client.DownloadStringTaskAsync(new Uri(url));
JObject root = JObject.Parse(response);
JArray items = (JArray)root["results"];
JObject item;
JToken jtoken;
item = (JObject)items[0];
JArray add_comp = (JArray)item["address_components"];
string address = null;
string[] add_types = { "street_number", "route", "neighborhood", "locality", "city", "country" };
foreach (var comp in add_comp)
{
if (add_types.Any(comp["types"].ToString().Contains))
{
address += comp["long_name"].ToString() + ", ";
if (comp["types"].ToString().Contains("city") | comp["types"].ToString().Contains("country"))
{
address += "\n";
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// Address From Google
/////////////////////////////////////////////////////////////End Google Code
(ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = true;
(ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true;
(ApplicationBar.Buttons[2] as ApplicationBarIconButton).IsEnabled = true;
(ApplicationBar.Buttons[3] as ApplicationBarIconButton).IsEnabled = true;
zzoom.IsEnabled = true;
positionLoaded = true;
Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
new_pushpin.Location = geo;
googlemap.Children.Remove(pushPinLayer);
pushPinLayer = new MapLayer();
new_pushpin.Content = address;
Address.Text = address;
new_pushpin.Visibility = Visibility.Visible;
googlemap.Children.Add(pushPinLayer);
pushPinLayer.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);
MainPage.bookingData.set_current_location_attributes(address,geo);
}
catch (Exception ex)
{
if ((uint)ex.HResult == 0x80004004)
{
// the application does not have the right capability or the location master switch is off
MessageBox.Show("location is disabled in phone settings");
}
//else
{
// something else happened acquring the location
}
}
}
示例12: OnActivate
protected override void OnActivate()
{
var map = ((FrameworkElement)GetView()).Descendants().OfType<Map>().SingleOrDefault(x => x.Name == "Location");
var layer = new MapLayer();
map.Children.Add(layer);
layer.AddChild(new Pushpin() { Background = new SolidColorBrush(Colors.Red), Content = Address }, Location);
base.OnActivate();
}
示例13: mapOnhold
private async void mapOnhold(object sender, System.Windows.Input.GestureEventArgs e)
{
googlemap.Children.Remove(pushPinLayer);
pushPinLayer = new MapLayer();
try
{
Point p = e.GetPosition(this.googlemap);
GeoCoordinate geo = new GeoCoordinate();
geo = googlemap.ViewportPointToLocation(p);
Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
new_pushpin.Location = geo;
// Storing in static variables
//Booking.SourceLat = geo.Latitude.ToString("0.000000");
//Booking.SourceLong = geo.Longitude.ToString("0.000000");
// Translating geocoordinates into address
string url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + geo.Latitude + "," + geo.Longitude + "&sensor=true";
var client = new WebClient();
string response = await client.DownloadStringTaskAsync(new Uri(url));
JObject root = JObject.Parse(response);
JArray items = (JArray)root["results"];
JObject item;
JToken jtoken;
item = (JObject)items[0];
JArray add_comp = (JArray)item["address_components"];
string address = null;
string[] add_types = { "street_number", "route", "neighborhood", "locality", "city", "country" };
foreach (var comp in add_comp)
{
if (add_types.Any(comp["types"].ToString().Contains))
{
address += comp["long_name"].ToString() + ", ";
if (comp["types"].ToString().Contains("city") | comp["types"].ToString().Contains("country"))
{
address += "\n";
}
}
}
new_pushpin.Content = address;
Address.Text = address;
new_pushpin.Visibility = Visibility.Visible;
// gPos.Coordinate.Latitude = geo.Latitude;
// gPos.Coordinate.Longitude=geo.Longitude;
googlemap.Children.Add(pushPinLayer);
pushPinLayer.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);
//MainPage.bookingData.set_current_location_attributes(address, geo);
LatitudeTextBlock.Text = "Latitude: " + geo.Latitude.ToString("0.000000"); //geoposition.Coordinate.Latitude.ToString("0.00"); //
LongitudeTextBlock.Text = "Longitude: " + geo.Longitude.ToString("0.000000");//geoposition.Coordinate.Longitude.ToString("0.00"); //
//MessageBox.Show(gPos.Coordinate.Latitude.ToString("0.000000"));
//MessageBox.Show(gPos.Coordinate.Longitude.ToString("0.000000"));
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists("track.txt"))
{
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
storage.DeleteFile("track.txt");
}
}
IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();
StreamWriter Writer = new StreamWriter(new IsolatedStorageFileStream("track.txt", FileMode.OpenOrCreate, fileStorage));
Writer.WriteLine(geo.Latitude.ToString("0.000000"));
Writer.WriteLine(geo.Longitude.ToString("0.000000"));
//MessageBox.Show(gPos.Coordinate.Latitude.ToString("0.000000"));
//MessageBox.Show(gPos.Coordinate.Longitude.ToString("0.000000"));
Writer.Close();
}
catch (Exception ed)
{
MessageBox.Show("Unable to Get Coordinates of Current Point");
}
}
示例14: routeService_CalculateRouteCompleted
void routeService_CalculateRouteCompleted(object sender, CalculateRouteCompletedEventArgs e)
{
RouteResponse response = e.Result;
if ((response.ResponseSummary.StatusCode == Panda.Phone.Publisher.RouteServiceReference.ResponseStatusCode.Success) && (response.Result.Legs.Count != 0))
{
Color color = Colors.Blue;
// SolidColorBrush brush = new SolidColorBrush(color);
SolidColorBrush brush = new SolidColorBrush(new Color() { R = 6, G = 128, B = 67, A = 255 });
MapPolyline line = new MapPolyline();
line.Locations = new LocationCollection();
line.Opacity = 0.6;
line.StrokeThickness = 10;
line.Stroke = brush;
//DispatcherTimer timer = new DispatcherTimer();
//timer.Interval = TimeSpan.FromMilliseconds(200);
//timer.Tick += new EventHandler(timer_Tick);
//timer.Start();
MapLayer layer = new MapLayer();
layer.Children.Add(line);
map.Children.Add(layer);
foreach (Location l in response.Result.RoutePath.Points)
{
line.Locations.Add(l);
}
//foreach (GeocodeResult r in Georesults)
//{
// Ellipse ellipse = new Ellipse();
// ellipse.Height = 10;
// ellipse.Width = 10;
// ellipse.Fill = new SolidColorBrush(Colors.Red);
// Location location = new Location()
// {
// Latitude = r.Locations[0].Latitude,
// Longitude = r.Locations[0].Longitude
// };
// layer.AddChild(ellipse, location);
//}
foreach (UserModel user in list_User_Choosed)
{
Ellipse ellipse = new Ellipse();
ellipse.Height = 10;
ellipse.Width = 10;
ellipse.Fill = new SolidColorBrush(new Color() { A = 0 });
Location location = new Location()
{
Latitude = user.Latitude,
Longitude = user.Longitude
};
layer.AddChild(ellipse, location);
}
//GeoCoordinate p = new GeoCoordinate(Georesults[1].Locations[0].Latitude, Georesults[1].Locations[0].Longitude);
// var routeModel = new RouteModel(e.Result.Result.RoutePath.Points);
// LocationRect rect = LocationRect.CreateLocationRect(routeModel.Locations);
// Set the map view using the rectangle which bounds the rendered route.
// map.SetView(p, 8);
}
}
示例15: ShowMap
void ShowMap()
{
myMap.Children.Clear();
List<Flight> selected = GetSelectedFlights();
if (selected.Count == 0)
{
// show everything.
selected.Add(new Flight() { StartTime = DateTime.MinValue, Duration = TimeSpan.MaxValue });
}
var glitchIcon = XamlExtensions.LoadImageResource("Assets.GpsGlitchIcon.png");
var imageLayer = new MapLayer();
myMap.Children.Add(imageLayer);
MapPolyline last = currentFlight;
foreach (IDataLog log in this.logs)
{
if (log != null)
{
bool gpsIsBad = false;
foreach (var flight in selected)
{
if (flight.Log == null || flight.Log == log)
{
MapPolyline line = new MapPolyline();
line.StrokeThickness = 4;
line.Stroke = new SolidColorBrush(HlsColor.GetRandomColor());
LocationCollection points = new LocationCollection();
Debug.WriteLine("time,\t\tlat,\t\tlong,\t\t\tnsat,\talt,\thdop,\tfix");
foreach (var row in log.GetRows("GPS", flight.StartTime, flight.Duration))
{
LogEntryGPS gps = new LogEntryGPS(row);
//Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.TimeMS, gps.Lat, gps.Lng, gps.NSats, gps.Alt, gps.HDop, gps.Fix);
if (!(gps.Lat == 0 && gps.Lon == 0))
{
var pos = new Location() { Altitude = gps.Alt, Latitude = gps.Lat, Longitude = gps.Lon };
points.Add(pos);
ulong time = (ulong)gps.GPSTime;
if (time != 0)
{
if ((gps.nSat < 5 || gps.EPH > 20))
{
if (!gpsIsBad)
{
gpsIsBad = true;
Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.GPSTime, gps.Lat, gps.Lon, gps.nSat, gps.Alt, gps.EPH, gps.Fix);
Image img = new Image();
img.Width = 30;
img.Height = 30;
img.Source = glitchIcon;
img.Stretch = Stretch.None;
img.ToolTip = "GPS Glitch!";
imageLayer.AddChild(img, pos, PositionOrigin.Center);
}
}
else
{
gpsIsBad = false;
}
}
}
}
if (points.Count > 0)
{
line.Locations = points;
myMap.Children.Add(line);
last = line;
}
}
}
}
}
ModelViewer.Visibility = Visibility.Collapsed;
Messages.Visibility = Visibility.Collapsed;
ChartStack.Visibility = Visibility.Collapsed;
TextButton.IsChecked = false;
myMap.Visibility = Visibility.Visible;
myMap.UpdateLayout();
if (last != null)
{
try
{
myMap.SetView(last.Locations, new Thickness(20.0), 0);
}
catch (Exception ex)
{
ShowStatus(ex.Message);
}
}
}