Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Device.Location;
- using Microsoft.Phone.Controls.Maps;
- using System.Windows;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- namespace La_Ruta_Maya.classes
- {
- public class Tuple<T1, T2, T3>
- {
- public T1 Latitude { get; set; }
- public T2 Longitude { get; set; }
- public T3 Name { get; set; }
- public Tuple(T1 item1, T2 item2, T3 item3)
- {
- Latitude = item1;
- Longitude = item2;
- Name = item3;
- }
- }
- class createMap
- {
- private Map mapLocation;
- private double Latitude;
- private double Longitude;
- private GeoCoordinateWatcher myCoordinateWatcher;
- public createMap(Map temp)
- {
- this.mapLocation = temp;
- }
- public void setCenter(double lat, double lon, double zoom, bool bar)
- {
- this.Latitude = lat;
- this.Longitude = lon;
- this.mapLocation.Center = new GeoCoordinate(this.Latitude, this.Longitude);
- this.mapLocation.ZoomLevel = zoom;
- if (bar == true)
- mapLocation.ZoomBarVisibility = Visibility.Visible;
- myCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
- myCoordinateWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(this.myCoordinateWatcher_PositionChanged);
- }
- private void myCoordinateWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
- {
- if (!e.Position.Location.IsUnknown)
- {
- Latitude = e.Position.Location.Latitude;
- Longitude = e.Position.Location.Longitude;
- mapLocation.Center = new GeoCoordinate(Latitude, Longitude);
- }
- }
- public void addPushpins(List<Tuple<double, double, string>> Values)
- {
- foreach (Tuple<double, double, string> location in Values ){
- ImageBrush ib = new ImageBrush();
- ib.ImageSource =
- new BitmapImage(new Uri("/images/ruin.png", UriKind.Relative));
- Pushpin pp = new Pushpin();
- pp.Template = null;
- pp.Location = new GeoCoordinate( location.Latitude, location.Longitude);
- pp.Content = new Rectangle()
- {
- Fill = ib,
- Opacity = .8,
- Height = 30,
- Width = 26
- };
- //pp.Content = location.Name; //Content for the Pushpin;
- mapLocation.Children.Add(pp); //myMap is your map control
- }
- }
- private void pushPin_Tap(object sender, System.Windows.Input.GestureEventArgs e)
- {
- // this.border.Visibility = System.Windows.Visibility.Visible;
- //stop the event from going to the parent map control
- e.Handled = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement