private void btnCongGiaoCoSo_Click(object sender, EventArgs e) { DataTable ds = wf.HienThiDSCoSo("", " where a.IDTonGiao=2"); //txtSoLuong.Text = ds.Rows.Count.ToString(); ItemStorage.Items.Clear(); //txtTen.Text = "Cả nước"; int i; for (i = 0; i < int.Parse(ds.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[i]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Có lỗi xảy ra"); } } mapCoSo.CenterPoint = new GeoPoint(latitude: 15.46056, longitude: 107.7433); mapCoSo.Zoom(5); }
void HienThiToanBoCacCoSoSoTheoTG() { DataTable ds = wf.HienThiDSCoSo("", " where a.IDCoSo=N'" + int.Parse(txtIDCoSo.Text) + "'"); DataTable ds2 = wf.HienThiDSCoSo("", " where a.TenTonGiao=N'" + ds.Rows[0]["TenTonGiao"].ToString() + "'"); int i; for (i = 0; i < int.Parse(ds2.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds2.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds2.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds2.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds2.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds2.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[0]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Có lỗi xảy ra"); } } }
private void map_MouseDoubleClick(object sender, MouseEventArgs e) { string x = map.CenterPoint.GetX().ToString(); string y = map.CenterPoint.GetY().ToString(); ItemStorage.Items.Clear(); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(y), float.Parse(x)), Text = "" }; var image = new Bitmap(imageFilePath + "0.png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample string[] x1 = x.Split(','); x1[1] = x1[1].Substring(0, 8); x = x1[0] + "." + x1[1]; //textBox2.Text = x; string[] y1 = y.Split(','); y1[1] = y1[1].Substring(0, 8); y = y1[0] + "." + y1[1]; txtVi.Text = y; txtKinh.Text = x; }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { Disaster disaster = item as Disaster; if (disaster == null) { return(base.SelectTemplate(item, container)); } MapCustomElement element = container as MapCustomElement; switch (disaster.Type) { case "Air Raids": return(AirRaidsDataTemplate); case "Bushfires": return(BushfiresDataTemplate); case "Cyclone": return(CycloneDataTemplate); case "Sinking": return(SinkingDataTemplate); case "Epidemic": return(EpidemicDataTemplate); default: return(base.SelectTemplate(item, container)); } }
void LoadFromXML(DataTemplate planeTemplate) { XDocument document = DataLoader.LoadXmlFromResources("/Data/FlightMap.xml"); if (document != null) { foreach (XElement element in document.Element("Planes").Elements()) { List <GeoPoint> points = new List <GeoPoint>(); foreach (XElement infoElement in element.Element("Path").Elements()) { GeoPoint geoPoint = new GeoPoint(Convert.ToDouble(infoElement.Element("Latitude").Value, CultureInfo.InvariantCulture), Convert.ToDouble(infoElement.Element("Longitude").Value, CultureInfo.InvariantCulture)); points.Add(geoPoint); } PlaneInfo info = new PlaneInfo(element.Element("PlaneName").Value, element.Element("PlaneID").Value, element.Element("EndPointName").Value, element.Element("StartPointName").Value, Convert.ToInt32(element.Element("Speed").Value), Convert.ToInt32(element.Element("Altitude").Value), points); info.CurrentFlightTime = Convert.ToDouble(element.Element("CurrentFlightTime").Value, CultureInfo.InvariantCulture); planesInfo.Add(info); } } foreach (PlaneInfo info in planesInfo) { MapCustomElement mapCustomElement = new MapCustomElement() { Content = info, ContentTemplate = planeTemplate }; BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty, new Binding("Position") { Source = info }); Planes.Add(mapCustomElement); AddPaths(info); } }
void HienThiToanBoCacCoSoSoTheoTinh() { map.CenterPoint = new GeoPoint(latitude: 21.04778, longitude: 105.8478); map.Zoom(12); ItemStorage.Items.Clear(); DataTable ds = wf.HienThiDSCoSo("", " where a.DiaChi in (select IDXa from tblXa,tblHuyen,tblTinh where tblXa.IDHuyen=tblHuyen.IDHuyen and tblHuyen.IDTinh=tblTinh.IDTinh and TenTinh=N'" + txtTen.Text + "') "); txtSoLuong.Text = ds.Rows.Count.ToString(); //DataTable ds2 = wf.HienThiDSCoSo("", " where a.TenTonGiao=N'" + ds.Rows[0]["TenTonGiao"].ToString() + "'"); if (int.Parse(ds.Rows.Count.ToString()) == 0) { MessageBox.Show("Thành phố " + txtTen.Text + " không có cơ sở tôn giáo"); } //xac dinh tam DataTable ds3 = wf.DuLieuTinh(" where TenTinh=N'" + txtTen.Text + "' "); DataTable ds4 = wf.DuLieuHuyen(" where IDTinh=N'" + ds3.Rows[0]["IDTinh"].ToString() + "'"); DataTable ds5 = wf.DuLieuXa("where IDHuyen=N'" + ds4.Rows[0]["IDHuyen"].ToString() + "'"); try { string ki = ds5.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = ds5.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); map.Zoom(12); } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { DataTable tv3 = wf.TimViTriTheoHuyen(" where IDHuyen=N'" + ds5.Rows[0]["IDHuyen"].ToString() + "'"); string ki = tv3.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = tv3.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); //map.Zoom(5); } int i; for (i = 0; i < int.Parse(ds.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[i]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Xảy ra lỗi"); } } }
void HienThiLenMapToChucQT() { DataTable ds2 = wf2.HienThiDSCoSo("", " where a.TenToChuc=N'" + txtTenToChuc.Text + "'"); ItemStorage.Items.Clear(); if (int.Parse(ds2.Rows.Count.ToString()) == 0) { //MessageBox.Show("Tổ chức quản trị " + txtTenToChuc.Text + " không có cơ sở tôn giáo !"); map.CenterPoint = new GeoPoint(latitude: 15.46056, longitude: 107.7433); map.Zoom(5); } else { int i; for (i = 0; i < int.Parse(ds2.Rows.Count.ToString()); i++) { // DataTable tv1 = wf2.TimViTri(" where IDXa=N'" + ds2.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds2.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds2.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds2.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds2.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath2 + ds2.Rows[0]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Xảy ra lỗi !"); } } //tim co so lam tam de hien thi int tam = int.Parse(ds2.Rows.Count.ToString()) / 2; DataTable tv4 = wf2.TimViTri(" where IDXa=N'" + ds2.Rows[tam]["DiaChi"].ToString() + "'"); try { string ki = tv4.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = tv4.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); map.Zoom(5); } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { DataTable tv3 = wf2.TimViTriTheoHuyen(" where IDHuyen=N'" + tv4.Rows[tam]["IDHuyen"].ToString() + "'"); string ki = tv3.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = tv3.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); map.Zoom(5); } } }
public SCMap AddCustomElement(double[] location, string text, CustomElementOptions options = null) { options ??= new CustomElementOptions(); var mapItem = new MapCustomElement(); options.ConfigurePointerItem(this, mapItem, location, text); return(this); }
private void SetFocusOnSelectedElement(MapCustomElement element) { var pointViewModel = element.Content as MapPointViewModel; foreach (var place in PlaceList) { place.IsSelected = false; } pointViewModel.IsSelected = true; }
protected override void InitializeItem(MapItem item, object obj) { CityWeather cityWeather = obj as CityWeather; MapCustomElement element = item as MapCustomElement; if (element == null || cityWeather == null) { return; } element.ImageUri = new Uri(cityWeather.WeatherIconPath); }
void OnPointerReleased(object sender, PointerRoutedEventArgs e) { MapCustomElement element = sender as MapCustomElement; if (element != null) { SelectedPlace = null; SelectedCity = ((CityInformationControl)element.Content).CityInfo; UpdateViewType(); e.Handled = true; } }
private void map_MouseDoubleClick(object sender, MouseEventArgs e) { Kinh = map.CenterPoint.GetX().ToString(); Vii = map.CenterPoint.GetY().ToString(); ItemStorage.Items.Clear(); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(Kinh), float.Parse(Vii)), Text = "" }; var image = new Bitmap(imageFilePath + "0.png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample }
void LoadDataFromXML(DataTemplate citySmallIconTemplate) { XDocument document = DataLoader.LoadFromXmlResource("MapDemo/Data/CitiesData.xml"); if (document != null) { foreach (XElement element in document.Element("Cities").Elements()) { string cityName = element.Element("CityName").Value; GeoPoint cityLocation = new GeoPoint(Convert.ToDouble(element.Element("Latitude").Value, CultureInfo.InvariantCulture), Convert.ToDouble(element.Element("Longitude").Value, CultureInfo.InvariantCulture)); CityInfo cityInfo = new CityInfo(cityName, cityLocation); foreach (XElement placeElement in element.Element("Places").Elements()) { string placeName = placeElement.Element("Name").Value; GeoPoint placeLocation = new GeoPoint(Convert.ToDouble(placeElement.Element("Latitude").Value, CultureInfo.InvariantCulture), Convert.ToDouble(placeElement.Element("Longitude").Value, CultureInfo.InvariantCulture)); string placeDescription = placeElement.Element("Description").Value; Uri placeImageUri = new Uri(placeElement.Element("ImageUri").Value, UriKind.RelativeOrAbsolute); BitmapImage image = new BitmapImage(placeImageUri); cityInfo.Places.Add(new PlaceInfo(placeName, cityName, placeLocation, placeDescription, image)); } CityInformationControl city = new CityInformationControl() { CityInfo = cityInfo }; Binding binding = new Binding() { Path = new PropertyPath("IsMapView"), Source = this }; city.SetBinding(CityInformationControl.VisibleProperty, binding); MapCustomElement mapItem = new MapCustomElement() { Content = city, Location = cityLocation }; mapItem.PointerReleased += OnPointerReleased; mapItem.PointerPressed += OnPointerPressed; Cities.Add(mapItem); CitySmallIcons.Add(new MapCustomElement() { Content = cityInfo, ContentTemplate = citySmallIconTemplate, Location = cityInfo.Location }); } } }
private void btnTimKiemCt_Click(object sender, EventArgs e) { try { DataTable ds = wf.HienThiDSCoSo("", " where a.DiaChi in (select IDXa from tblXa ,tblHuyen,tblTinh where tblXa.IDHuyen=tblHuyen.IDHuyen and tblHuyen.IDTinh=tblTinh.IDTinh and TenXa=N'" + cboXa.Text + "' and TenHuyen=N'" + cboHuyen.Text + "' and TenTinh=N'" + cboTinh.Text + "') and a.TenToChuc=N'" + cboTenToChucQuanTri.Text + "'"); txtSoLuong.Text = ds.Rows.Count.ToString(); DataTable xa = wf.DuLieuXa(" ,tblHuyen,tblTinh where tblXa.IDHuyen=tblHuyen.IDHuyen and tblHuyen.IDTinh=tblTinh.IDTinh and TenXa=N'" + cboXa.Text + "' and TenHuyen=N'" + cboHuyen.Text + "' and TenTinh=N'" + cboTinh.Text + "'"); ItemStorage.Items.Clear(); string ki1 = xa.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi1 = xa.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: (float.Parse(ki1)), longitude: (float.Parse(vi1))); for (int i = 0; i < ds.Rows.Count; i++) { string ki = ds.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = ds.Rows[i]["TenCoSo"].ToString() + "- Địa chỉ: " + ds.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[i]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample*/ map.Zoom(15); } } catch { MessageBox.Show("Không có dữ liệu về cơ sở tôn giáo tại " + cboXa.Text); try { DataTable ds = wf.DuLieuXa(" ,tblHuyen,tblTinh where tblXa.IDHuyen=tblHuyen.IDHuyen and tblHuyen.IDTinh=tblTinh.IDTinh and TenXa=N'" + cboXa.Text + "' and TenHuyen=N'" + cboHuyen.Text + "' and TenTinh=N'" + cboTinh.Text + "'"); DataTable ds2 = wf.DuLieuTonGiao(" where TenTonGiao=N'" + cboTonGiao.Text + "'"); string ki1 = ds.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi1 = ds.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: (float.Parse(ki1)), longitude: (float.Parse(vi1))); } catch { MessageBox.Show("Không thể hiển thị tôn giáo do chưa có icon tôn giáo"); } } }
private void button2_Click_1(object sender, EventArgs e) { //DataTable ds = wf.HienThiDSCoSo("", " where a.IDCoSo=N'" + int.Parse(txtIDCoSo.Text) + "'"); DataTable ds2 = wf.HienThiDSCoSo("", " where a.TenTonGiao=N'" + cboTenTonGiao.Text + "'"); ItemStorage.Items.Clear(); if (int.Parse(ds2.Rows.Count.ToString()) == 0) { MessageBox.Show(cboTenTonGiao.Text + " không có cơ sở tôn giáo !"); map.CenterPoint = new GeoPoint(latitude: 15.46056, longitude: 107.7433); map.Zoom(5); } else { int i; for (i = 0; i < int.Parse(ds2.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds2.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds2.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds2.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds2.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds2.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds2.Rows[0]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Xảy ra lỗi"); } } map.CenterPoint = new GeoPoint(latitude: 15.46056, longitude: 107.7433); map.Zoom(5); } }
private void LoadMap(int IDTrip) { var image = new Bitmap(imageFilePath); var sv = new Position1SoapClient(); var listPosition = sv.GetAllPo(IDTrip).ToList(); MapPolyline mp = new MapPolyline(); mp.Fill = Color.White; listPosition.OrderBy(p => p.Time).ToList(); foreach (var p in listPosition) { mp.Points.Add(new GeoPoint(Convert.ToDouble(p.Latitude), Convert.ToDouble(p.Longitude))); var customElement = new MapCustomElement() { Location = new GeoPoint(Convert.ToDouble(p.Latitude), Convert.ToDouble(p.Longitude)), Text = "" }; customElement.Image = new Bitmap(image, new Size(40, 40)); mapItemStorage1.Items.Add(customElement); } ((MapItemStorage)VectorLayer.Data).Items.Add(mp); }
private void Init(DataTemplate template) { Random random = new Random(DateTime.Now.Millisecond); foreach (var info in _mapPointsInfo) { var mapPointViewModel = new MapPointViewModel(info) { Count = _mapNameToCount[info.Name] }; mapPointViewModel.Zoom = Zoom; mapPointViewModel.MapPointColor = new SolidColorBrush(Color.FromRgb( (byte)random.Next(1, 255), (byte)random.Next(1, 255), (byte)random.Next(1, 255))); PlaceList.Add(mapPointViewModel); _mapNameToMapPoint.Add(mapPointViewModel.Name, mapPointViewModel); var mapCustomElement = new MapCustomElement() { Content = mapPointViewModel, ContentTemplate = template, }; _mapNameToMapElement.Add(info.Name, mapCustomElement); mapCustomElement.MouseLeftButtonDown += OnMapCustomElementClick; BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty, new Binding("Location") { Source = mapPointViewModel }); MapElements.Add(mapCustomElement); } }
void LoadShipwrecks() { string xmlFilepath = Path.Combine(Package.Current.InstalledLocation.Path, filepath); XDocument document = XDocument.Load(xmlFilepath); foreach (XElement element in document.Element("Ships").Elements()) { GeoPoint location = new GeoPoint() { Latitude = Convert.ToDouble(element.Element("Latitude").Value, CultureInfo.InvariantCulture), Longitude = Convert.ToDouble(element.Element("Longitude").Value, CultureInfo.InvariantCulture) }; MapCustomElement e = new MapCustomElement() { Location = location, ContentTemplate = this.Resources["itemTemplate"] as DataTemplate }; e.Attributes.Add(new MapItemAttribute() { Name = "Description", Value = element.Element("Description").Value }); e.Attributes.Add(new MapItemAttribute() { Name = "Name", Value = element.Element("Name").Value }); e.Attributes.Add(new MapItemAttribute() { Name = "Year", Value = element.Element("Year").Value }); shipwrecks.Add(e); } }
private void SetFocusOnSelectedElement(MapCustomElement element) { var pointViewModel = element.Content as MapPointViewModel; foreach (var place in PlaceList) place.IsSelected = false; pointViewModel.IsSelected = true; }
private void Form1_Load(object sender, System.EventArgs e) { #region #MapDotExample ItemStorage.Items.Add(new MapDot() { Location = new GeoPoint(-10, 10), Size = 18, Stroke = Color.Blue }); #endregion #MapDotExample #region #MapEllipseExample ItemStorage.Items.Add(new MapEllipse() { Location = new GeoPoint(40, 40), Height = 300, Width = 600 }); #endregion #MapEllipseExample #region #MapLineExample ItemStorage.Items.Add(new MapLine { Point1 = new GeoPoint(-30, 20), Point2 = new GeoPoint(-35, 25), Stroke = Color.Red, StrokeWidth = 4 }); #endregion #MapLineExample #region #MapCalloutExample ItemStorage.Items.Add(new MapCallout() { Location = new GeoPoint(10, 10), Text = "This is a MapCallout object" }); #endregion #MapCalloutExample #region #MapPathExample var path = new MapPath(); var segment = new MapPathSegment(); segment.Points.AddRange(new GeoPoint[] { new GeoPoint(20, 20), new GeoPoint(20, 30), new GeoPoint(30, 30) }); path.Segments.Add(segment); segment = new MapPathSegment(); segment.Points.AddRange(new GeoPoint[] { new GeoPoint(30, 32), new GeoPoint(20, 32), new GeoPoint(20, 42) }); path.Segments.Add(segment); ItemStorage.Items.Add(path); #endregion #MapPathExample #region #MapPolygonExample var polygon = new MapPolygon(); polygon.Points.AddRange(new GeoPoint[] { new GeoPoint(70, 80), new GeoPoint(75, 90), new GeoPoint(75, 130) }); ItemStorage.Items.Add(polygon); #endregion #MapPolygonExample #region #MapPolylineExample var polyline = new MapPolyline() { StrokeWidth = 4, Stroke = Color.Yellow }; polyline.Points.AddRange(new GeoPoint[] { new GeoPoint(-29, 130), new GeoPoint(-40, 140), new GeoPoint(-20, 150) }); ItemStorage.Items.Add(polyline); #endregion #MapPolylineExample #region #MapPushpinExample ItemStorage.Items.Add(new MapPushpin() { Location = new GeoPoint(70, -100), Text = "1" }); #endregion #MapPushpinExample #region #MapRectangleExample ItemStorage.Items.Add(new MapRectangle() { Location = new GeoPoint(-70, -100), Width = 500, Height = 750 }); #endregion #MapRectangleExample #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(50, 50), Text = "This is a MapCustomElement object" }; var image = new Bitmap(imageFilePath); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample #region #MapBubbleExample ItemStorage.Items.Add(new MapBubble() { Location = new GeoPoint(30, 20), Value = 400, Argument = "A", Size = 100 }); #endregion #MapBubbleExample #region #MapPieExample var pie = new MapPie() { Location = new GeoPoint(-20, -30), Size = 100 }; pie.Segments.AddRange(new PieSegment[] { new PieSegment() { Argument = "A", Value = 2 }, new PieSegment() { Argument = "B", Value = 3 }, new PieSegment() { Argument = "C", Value = 4 } }); ItemStorage.Items.Add(pie); #endregion #MapPieExample }
private void btnConggiao_Click(object sender, EventArgs e) { //click vÀo các tên tỉnh if (txtTen.Text == "Địa giới hành chính" || txtTen.Text == "Thành phố trực thuộc Trung ương" || txtTen.Text == "Khu vực địa giới hành chính" || txtTen.Text == "" || txtTen.Text == "Cả nước") { DataTable ds = wf.HienThiDSCoSo("", " where a.IDTonGiao=2"); txtSoLuong.Text = ds.Rows.Count.ToString(); ItemStorage.Items.Clear(); txtTen.Text = "Cả nước"; int i; for (i = 0; i < int.Parse(ds.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[i]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Có lỗi xảy ra"); } } map.CenterPoint = new GeoPoint(latitude: 15.46056, longitude: 107.7433); map.Zoom(5); } DataTable ds1 = wf.DuLieuTinh(" where TenTinh=N'" + txtTen.Text + "'"); if (int.Parse(ds1.Rows.Count.ToString()) == 1) { map.CenterPoint = new GeoPoint(latitude: 21.04778, longitude: 105.8478); map.Zoom(12); ItemStorage.Items.Clear(); DataTable ds = wf.HienThiDSCoSo("", " where a.DiaChi in (select IDXa from tblXa,tblHuyen,tblTinh where tblXa.IDHuyen=tblHuyen.IDHuyen and tblHuyen.IDTinh=tblTinh.IDTinh and TenTinh=N'" + txtTen.Text + "') and a.IDTonGiao=2"); txtSoLuong.Text = ds.Rows.Count.ToString(); //DataTable ds2 = wf.HienThiDSCoSo("", " where a.TenTonGiao=N'" + ds.Rows[0]["TenTonGiao"].ToString() + "'"); if (int.Parse(ds.Rows.Count.ToString()) == 0) { MessageBox.Show("Thành phố " + txtTen.Text + " không có cơ sở tôn giáo"); } //xac dinh tam DataTable ds3 = wf.DuLieuTinh(" where TenTinh=N'" + txtTen.Text + "' "); DataTable ds4 = wf.DuLieuHuyen(" where IDTinh=N'" + ds3.Rows[0]["IDTinh"].ToString() + "'"); DataTable ds5 = wf.DuLieuXa("where IDHuyen=N'" + ds4.Rows[0]["IDHuyen"].ToString() + "'"); try { string ki = ds5.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = ds5.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); map.Zoom(12); } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { DataTable tv3 = wf.TimViTriTheoHuyen(" where IDHuyen=N'" + ds5.Rows[0]["IDHuyen"].ToString() + "'"); string ki = tv3.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = tv3.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); //map.Zoom(5); } int i; for (i = 0; i < int.Parse(ds.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[i]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Có lỗi xảy ra"); } } } //click vao khu vuc DataTable ds2 = wf.DuLieuVung(" where TenVungDiaLy=N'" + txtTen.Text + "'"); if (int.Parse(ds2.Rows.Count.ToString()) == 1) { DataTable ds3 = wf.DuLieuTinh(" where IDVungDiaLy=N'" + ds2.Rows[0]["IDVungDiaLy"].ToString() + "' "); int tam = int.Parse(ds3.Rows.Count.ToString()) / 2; DataTable ds4 = wf.DuLieuHuyen(" where IDTinh=N'" + ds3.Rows[tam]["IDTinh"].ToString() + "'"); DataTable ds5 = wf.DuLieuXa("where IDHuyen=N'" + ds4.Rows[0]["IDHuyen"].ToString() + "'"); try { string ki = ds5.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = ds5.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); map.Zoom(7); } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { DataTable tv3 = wf.TimViTriTheoHuyen(" where IDHuyen=N'" + ds5.Rows[tam]["IDHuyen"].ToString() + "'"); string ki = tv3.Rows[0]["ViDo"].ToString().Replace(".", ","); string vi = tv3.Rows[0]["KinhDo"].ToString().Replace(".", ","); map.CenterPoint = new GeoPoint(latitude: float.Parse(ki), longitude: float.Parse(vi)); map.Zoom(7); } //hien thi toan bo cs ton giao len map theo vung //txtTen.Text = e.Node.Text; if (int.Parse(ds2.Rows.Count.ToString()) == 1) { DataTable ds = wf.HienThiDSCoSo("", " where a.DiaChi in (select IDXa from tblXa,tblHuyen,tblTinh,tblVungDiaLy where tblXa.IDHuyen=tblHuyen.IDHuyen and tblHuyen.IDTinh=tblTinh.IDTinh and tblVungDiaLy.IDVungDiaLy=tblTinh.IDVungDiaLy and TenVungDiaLy=N'" + txtTen.Text + "') and a.IDTonGiao=2"); txtSoLuong.Text = ds.Rows.Count.ToString(); ItemStorage.Items.Clear(); //txtTen.Text = e.Node.Text; int i; for (i = 0; i < int.Parse(ds.Rows.Count.ToString()); i++) { //DataTable tv1 = wf.TimViTri(" where IDXa=N'" + ds.Rows[i]["DiaChi"].ToString() + "'"); try { string ki = ds.Rows[i]["ViDo"].ToString().Replace(".", ","); string vi = ds.Rows[i]["KinhDo"].ToString().Replace(".", ","); #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(float.Parse(ki), float.Parse(vi)), Text = "" + ds.Rows[i]["TenCoSo"].ToString() + "-Địa chỉ: " + ds.Rows[i]["TenXa"].ToString() }; var image = new Bitmap(imageFilePath + ds.Rows[0]["IDTonGiao"].ToString() + ".png"); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample } catch//trong truong hop không có tọa độ xã->lấy tọa độ của huyện { MessageBox.Show("Có lỗi xảy ra"); } } } } }
private void Init(DataTemplate template) { Random random = new Random(DateTime.Now.Millisecond); foreach (var info in _mapPointsInfo) { var mapPointViewModel = new MapPointViewModel(info) { Count = _mapNameToCount[info.Name]}; mapPointViewModel.Zoom = Zoom; mapPointViewModel.MapPointColor = new SolidColorBrush(Color.FromRgb( (byte)random.Next(1, 255), (byte)random.Next(1, 255), (byte)random.Next(1, 255))); PlaceList.Add(mapPointViewModel); _mapNameToMapPoint.Add(mapPointViewModel.Name, mapPointViewModel); var mapCustomElement = new MapCustomElement() { Content = mapPointViewModel, ContentTemplate = template, }; _mapNameToMapElement.Add(info.Name, mapCustomElement); mapCustomElement.MouseLeftButtonDown += OnMapCustomElementClick; BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty, new Binding("Location") { Source = mapPointViewModel }); MapElements.Add(mapCustomElement); } }