public PositionMarker(SystemPage systemPage, GMapMarker currentMarker, TrolleyTooltip trolleyToolTip, bool p) { // TODO: Complete member initialization this.systemPage = systemPage; this.currentMarker = currentMarker; this.trolleyToolTip = trolleyToolTip; this.p = p; }
//初始化一级页面 private void initGrid1( ) { MainMap.CurrentPosition = new PointLatLng(30.67, 104.06); MainMap.MaxZoom = 14; MainMap.MinZoom = 12; MainMap.Zoom = 12; MainMap.MapType = MapType.GoogleHybridChina; MainMap.Manager.Mode = AccessMode.CacheOnly; MainMap.BoundsOfMap = new RectLatLng(30.67, 104.06, 0.025, 0.018); //北纬30.67度,东经104.06度。 MainMap.CanDragMap = true; markers = new GMapMarker[4]; markers[0] = new GMapMarker(new PointLatLng(30.6614600000, 104.0835370000)); markers[1] = new GMapMarker(new PointLatLng(30.6660890000, 104.0360580000)); markers[2] = new GMapMarker(new PointLatLng(30.6614600000, 104.0835370000)); markers[3] = new GMapMarker(new PointLatLng(30.7686670000, 103.9919190000)); currentMarker = new GMapMarker(MainMap.CurrentPosition); { TrolleyTooltip trolleyToolTip = new TrolleyTooltip(); // trolleyToolTip.setStatus("异常"); currentMarker.Shape = new CustomMarkerRed(this, currentMarker, trolleyToolTip, this); currentMarker.Offset = new System.Windows.Point(0, 0); currentMarker.ZIndex = int.MaxValue; MainMap.Markers.Add(currentMarker); for (int i = 0; i < markers.Length; i++) { if (i % 2 == 0) { trolleyToolTip = new TrolleyTooltip(); markers[i].Shape = new CustomMarkerRed(this, markers[i], trolleyToolTip, this); } else { trolleyToolTip = new TrolleyTooltip(); markers[i].Shape = new CustomMarkerGreen(this, markers[i], trolleyToolTip, this); } markers[i].Offset = new System.Windows.Point(0, 0); markers[i].ZIndex = int.MaxValue; MainMap.Markers.Add(markers[i]); } } }
//更新地图界面数据 public void updateMapUI() { Dictionary <string, Building> buildings = GlobalMapForShow.globalMapForBuiding; if (markers != null && markers.Length > 0) { for (int i = 0; i < markers.Length; i++) { Building b = ((PositionMarker)(markers[i].Shape)).building; Building b2 = buildings[b.SystemId + ""]; if (b2.State != b.State) //异常和正常状态的切换 { TrolleyTooltip trolleyToolTip = new TrolleyTooltip(b); markers[i].Shape = new PositionMarker(mainWindow, markers[i], trolleyToolTip, buildings[b.SystemId + ""]); } } } }
private void initLittleMap() { PointLatLng point = mainWindow.getClickPoint(); map.CurrentPosition = new PointLatLng(point.Lat, point.Lng); map.MaxZoom = 40; map.MinZoom = 1; map.Zoom = 7; // map.MapType = MapType.GoogleHybridChina ; map.MapType = MapType.ArcGIS_Map; map.Manager.Mode = AccessMode.ServerAndCache; // map.BoundsOfMap = new RectLatLng(29.540871 , 104.804598 , 20.025, 20.018); //北纬30.67度,东经104.06度。 map.CanDragMap = true; map.MouseWheel += new MouseWheelEventHandler(map_MouseWheel); map.DragButton = MouseButton.Right; currentMarker = new GMapMarker(new PointLatLng(31.540871, 104.804598)); { TrolleyTooltip trolleyToolTip = new TrolleyTooltip(); currentMarker.ZIndex = int.MaxValue; map.Markers.Add(currentMarker); //currentMarker.Shape = new PositionMarker(mainWindow, currentMarker, trolleyToolTip, false); for (int i = 0; i < markers.Length; i++) { if (markers[i] != null) { break; } markers[i].ZIndex = int.MaxValue; trolleyToolTip = new TrolleyTooltip(mainWindow.Buildings[i]); markers[i].Shape = new PositionMarker(mainWindow, markers[i], trolleyToolTip, mainWindow.Buildings[i]); markers[i].Shape.AllowDrop = false; map.Markers.Add(markers[i]); } } }
public MainWindow() { InitializeComponent(); // map events MainMap.OnCurrentPositionChanged += new CurrentPositionChanged(MainMap_OnCurrentPositionChanged); MainMap.OnTileLoadComplete += new TileLoadComplete(MainMap_OnTileLoadComplete); MainMap.OnTileLoadStart += new TileLoadStart(MainMap_OnTileLoadStart); MainMap.OnMapTypeChanged += new MapTypeChanged(MainMap_OnMapTypeChanged); // MainMap.MouseMove += new System.Windows.Input.MouseEventHandler(MainMap_MouseMove); MainMap.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(MainMap_MouseLeftButtonDown); // MainMap.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(clickCurrentMarker); MainMap.Loaded += new RoutedEventHandler(MainMap_Loaded); //MainMap.MouseEnter += new MouseEventHandler(MainMap_MouseEnter); MainMap.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(MainMap_MouseWheelScroll); map.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(Map1_MouseWheelScroll); map.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(Map_DoubleClick); CabList.MouseDoubleClick += new MouseButtonEventHandler(Cablist_DoubleClick); CabList.MouseRightButtonDown += new MouseButtonEventHandler(Delete_Cab); RedMarkerCickPoint = new PointLatLng(); initGrid1(); initGrid2(RedMarkerCickPoint); zoomSlider.Maximum = MainMap.MaxZoom; zoomSlider.Minimum = MainMap.MinZoom; //if(false) { // add my city location for demo GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; PointLatLng?city = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius", out status); if (city != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { GMapMarker it = new GMapMarker(city.Value); { it.ZIndex = 55; TrolleyTooltip trolleyToolTip1 = new TrolleyTooltip(); it.Shape = new CustomMarkerGreen(this, it, trolleyToolTip1); } MainMap.Markers.Add(it); #region -- add some markers and zone around them -- { List <PointAndInfo> objects = new List <PointAndInfo>(); { string area = "Antakalnis"; PointLatLng?pos = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius, " + area, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { objects.Add(new PointAndInfo(pos.Value, area)); } } { string area = "Senamiestis"; PointLatLng?pos = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius, " + area, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { objects.Add(new PointAndInfo(pos.Value, area)); } } { string area = "Pilaite"; PointLatLng?pos = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius, " + area, out status); if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) { objects.Add(new PointAndInfo(pos.Value, area)); } } AddDemoZone(8.8, city.Value, objects); } #endregion } } // perfromance test timer.Interval = TimeSpan.FromMilliseconds(44); timer.Tick += new EventHandler(timer_Tick); // transport demo transport.DoWork += new DoWorkEventHandler(transport_DoWork); transport.ProgressChanged += new ProgressChangedEventHandler(transport_ProgressChanged); transport.WorkerSupportsCancellation = true; transport.WorkerReportsProgress = true; }
private void initMap() { // add your custom map db provider //MySQLPureImageCache ch = new MySQLPureImageCache(); //ch.ConnectionString = @"server=sql2008;User Id=trolis;Persist Security Info=True;database=gmapnetcache;password=trolis;"; //MainMap.Manager.ImageCacheSecond = ch; // set your proxy here if need // MainMap.Manager.Proxy = new WebProxy("10.2.0.100", 8080); // MainMap.Manager.Proxy.Credentials = new NetworkCredential("*****@*****.**", "bilgeadam"); // set cache mode only if no internet avaible //try //{ // System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com"); //} //catch //{ // MainMap.Manager.Mode = AccessMode.CacheOnly; // MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - Demo.WindowsPresentation", MessageBoxButton.OK, MessageBoxImage.Warning); //} Console.WriteLine("initMap"); this.MouseMove += new MouseEventHandler(Window_MouseMove); // this.MouseUp += new MouseButtonEventHandler(Window_MouseUp); MainMap.OnCurrentPositionChanged += new CurrentPositionChanged(MainMap_OnCurrentPositionChanged); MainMap.MouseMove += new System.Windows.Input.MouseEventHandler(MainMap_MouseMove); MainMap.Loaded += new RoutedEventHandler(MainMap_Loaded); MainMap.MouseEnter += new MouseEventHandler(MainMap_MouseEnter); MainMap.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(MainMap_MouseWheelScroll); MainMap.CurrentPosition = new PointLatLng(31.540871, 104.804598); MainMap.MaxZoom = 40; MainMap.MinZoom = 2; MainMap.Zoom = 6; // MainMap.MapType = MapType.GoogleHybridChina; MainMap.MapType = MapType.ArcGIS_Map; MainMap.Manager.Mode = AccessMode.CacheOnly; //MainMap.BoundsOfMap = new RectLatLng(31.540871, 104.804598, 2.025, 2.018); //北纬30.67度,东经104.06度。 MainMap.CanDragMap = true; MainMap.DragButton = MouseButton.Right; currentMarker = new GMapMarker(new PointLatLng(31.540871, 104.804598)); { TrolleyTooltip trolleyToolTip = new TrolleyTooltip(); // trolleyToolTip.setStatus("异常"); // currentMarker.Offset = new System.Windows.Point(0,0); currentMarker.ZIndex = int.MaxValue; MainMap.Markers.Add(currentMarker); // currentMarker.Shape = new PositionMarker(mainWindow, currentMarker, trolleyToolTip, false); for (int i = 0; i < markers.Length; i++) { markers[i].ZIndex = int.MaxValue; trolleyToolTip = new TrolleyTooltip(buildings[i]); markers[i].Shape = new PositionMarker(mainWindow, markers[i], trolleyToolTip, buildings[i]); // markers[i].Shape.MouseRightButtonDown += new MouseButtonEventHandler(Marker_MouseRightButtonDown); // markers[i].Shape.MouseDown += new MouseButtonEventHandler(marker_Click); markers[i].Shape.MouseLeftButtonUp += marker_Click; markers[i].Shape.AllowDrop = true; markers[i].Shape.PreviewMouseMove += Shape_PreviewMouseMove; markers[i].Shape.QueryContinueDrag += Shape_QueryContinueDrag; MainMap.Markers.Add(markers[i]); } } }
public MainWindow2() { InitializeComponent(); // add your custom map db provider //MySQLPureImageCache ch = new MySQLPureImageCache(); //ch.ConnectionString = @"server=sql2008;User Id=trolis;Persist Security Info=True;database=gmapnetcache;password=trolis;"; //MainMap.Manager.ImageCacheSecond = ch; // set your proxy here if need //MainMap.Manager.Proxy = new WebProxy("10.2.0.100", 8080); //MainMap.Manager.Proxy.Credentials = new NetworkCredential("*****@*****.**", "bilgeadam"); // set cache mode only if no internet avaible //try //{ // System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com.hk"); //} //catch //{ // MainMap.Manager.Mode = AccessMode.CacheOnly; // MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - Demo.WindowsPresentation", MessageBoxButton.OK, MessageBoxImage.Warning); //} // config map // map events MainMap.OnCurrentPositionChanged += new CurrentPositionChanged(MainMap_OnCurrentPositionChanged); MainMap.OnTileLoadComplete += new TileLoadComplete(MainMap_OnTileLoadComplete); MainMap.OnTileLoadStart += new TileLoadStart(MainMap_OnTileLoadStart); MainMap.OnMapTypeChanged += new MapTypeChanged(MainMap_OnMapTypeChanged); MainMap.MouseMove += new System.Windows.Input.MouseEventHandler(MainMap_MouseMove); MainMap.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(MainMap_MouseLeftButtonDown); MainMap.Loaded += new RoutedEventHandler(MainMap_Loaded); MainMap.MouseEnter += new MouseEventHandler(MainMap_MouseEnter); MainMap.CurrentPosition = new PointLatLng(54.6861334816182, 25.3185095977783); MainMap.MaxZoom = 16; MainMap.MinZoom = 14; MainMap.Zoom = 15; MainMap.MapType = MapType.GoogleHybridChina; MainMap.Manager.Mode = AccessMode.ServerAndCache; MainMap.BoundsOfMap = new RectLatLng(54.6991334816182, 25.3085095977783, 0.025, 0.018); //MainMap.BoundsOfMap = new RectLatLng(54.6961334816182, 25.2985095977783, 54.6961334816182-54.6777515392851, 25.3453731536865-25.2985095977783); //// get map types //comboBoxMapType.ItemsSource = Enum.GetValues(typeof(MapType)); //// acccess mode //comboBoxMode.ItemsSource = Enum.GetValues(typeof(AccessMode)); //comboBoxMode.SelectedItem = MainMap.Manager.Mode; // get cache modes // checkBoxCacheRoute.IsChecked = MainMap.Manager.UseRouteCache; // checkBoxGeoCache.IsChecked = MainMap.Manager.UseGeocoderCache; // setup zoom min/max // sliderZoom.Maximum = MainMap.MaxZoom; // sliderZoom.Minimum = MainMap.MinZoom; // get position //Lat=54.6961334816182, Lng=25.2985095977783} // textBoxLat.Text = MainMap.CurrentPosition.Lat.ToString(CultureInfo.InvariantCulture); // textBoxLng.Text = MainMap.CurrentPosition.Lng.ToString(CultureInfo.InvariantCulture); // get marker state // checkBoxCurrentMarker.IsChecked = true; // can drag map // checkBoxDragMap.IsChecked = MainMap.CanDragMap; #if DEBUG // checkBoxDebug.IsChecked = true; #endif // set current marker marker = new GMapMarker(MainMap.CurrentPosition); { TrolleyTooltip trolleyToolTip = new TrolleyTooltip(); Console.WriteLine("132"); // marker.Shape = new CustomMarkerRed(this, marker,trolleyToolTip); // marker.Shape = new CustomMarkerRed(this, marker, trolleyToolTip); marker.Offset = new System.Windows.Point(-15, -15); marker.ZIndex = int.MaxValue; MainMap.Markers.Add(marker); } /* * //if(false) * { * // add my city location for demo * GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; * * PointLatLng? city = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius", out status); * if(city != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) * { * GMapMarker it = new GMapMarker(city.Value); * { * it.ZIndex = 55; * TrolleyTooltip trolleyToolTip1 = new TrolleyTooltip(); * it.Shape = new CustomMarkerDemo(this, it, trolleyToolTip1); * } * MainMap.Markers.Add(it); * #region -- add some markers and zone around them -- * { * List<PointAndInfo> objects = new List<PointAndInfo>(); * { * string area = "Antakalnis"; * PointLatLng? pos = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius, " + area, out status); * if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) * { * objects.Add(new PointAndInfo(pos.Value, area)); * } * } * { * string area = "Senamiestis"; * PointLatLng? pos = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius, " + area, out status); * if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) * { * objects.Add(new PointAndInfo(pos.Value, area)); * } * } * { * string area = "Pilaite"; * PointLatLng? pos = GMaps.Instance.GetLatLngFromGeocoder("Lithuania, Vilnius, " + area, out status); * if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) * { * objects.Add(new PointAndInfo(pos.Value, area)); * } * } * AddDemoZone(8.8, city.Value, objects); * } #endregion * } * } * */ // perfromance test timer.Interval = TimeSpan.FromMilliseconds(44); timer.Tick += new EventHandler(timer_Tick); // transport demo transport.DoWork += new DoWorkEventHandler(transport_DoWork); transport.ProgressChanged += new ProgressChangedEventHandler(transport_ProgressChanged); transport.WorkerSupportsCancellation = true; transport.WorkerReportsProgress = true; }