public RoutePointMarker(GMap.NET.PointLatLng p, int routePointIndex, GMapRoute route) : base(p) { _route = route; _routePointIndex = routePointIndex; base.Size = new Size(8, 8); base.Offset = new Point((-1) * base.Size.Width / 2, (-1) * base.Size.Height / 2); }
public GMap Read(Stream MapStream) { var header = _headerReader.Read(MapStream); var postReader = _postReaderFactory(header); var map = new GMap(header); var postCounter = 0; var sectionCounter = 0; while (postCounter < header.PostsCount) { var section = new GSection(++sectionCounter); GPost post; do { post = postReader.Read(MapStream, section.Id); section.Posts.Add(post); postCounter++; } while (post.Position != PositionInSection.End); map.Sections.Add(section); } return(map); }
private void BuscarDireccion(string datos) { string region, provincia, comuna; GLatLng coordenadas; if (!string.IsNullOrEmpty(datos)) { string key = ConfigurationManager.AppSettings.Get("googlemaps.subgurim.net"); GeoCode geocode = GMap.geoCodeRequest(datos, key, new GLatLngBounds(new GLatLng(40, 10), new GLatLng(50, 20))); try { if ((null != geocode) && geocode.valid) { region = geocode.Placemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName; provincia = geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName; comuna = geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName; hdDireccion.Value = geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName; coordenadas = geocode.Placemark.coordinates; hdLatitud.Value = coordenadas.lat.ToString(); hdLongitud.Value = coordenadas.lng.ToString(); CargarMapa(region, provincia, comuna, hdDireccion.Value, coordenadas); } else { Response.Write("<script language=javascript>alert('DIRECCION INCORRECTA');</script>"); } } catch (Exception ex) { Response.Write("<script language=javascript>alert('" + ex.ToString() + "');</script>"); } } }
public void mapa(double lat, double lon, string _nombres, int _items_entregados, int _entregas) { GLatLng ubicacion = new GLatLng(lat, lon); GMap.setCenter(ubicacion, 15); //Establecemos alto y ancho en px GMap.Height = 600; GMap.Width = 940; //Adiciona el control de la parte izq superior (moverse, ampliar y reducir) GMap.Add(new GControl(GControl.preBuilt.LargeMapControl)); //GControl.preBuilt.MapTypeControl: permite elegir un tipo de mapa y otro. GMap.Add(new GControl(GControl.preBuilt.MapTypeControl)); //Con esto podemos definir el icono que se mostrara en la ubicacion //#region Crear Icono GIcon iconPropio = new GIcon(); iconPropio.image = "../Images/marcadornestle1.png"; iconPropio.shadow = "../Images/marcadorsombranestle1.png";; iconPropio.iconSize = new GSize(32, 32); iconPropio.shadowSize = new GSize(29, 16); iconPropio.iconAnchor = new GPoint(10, 18); iconPropio.infoWindowAnchor = new GPoint(10, 9); //#endregion //Pone la marca de gota de agua con el nombre de la ubicacion GMarker marker = new GMarker(ubicacion, iconPropio); string strMarker = "<div style='width: 200px; border-radius: 35px; ; height: 150px'><b>" + "<span style='color:#ff7e00'>Establecimiento: </span>" + _nombres + "</b><br>" + " Items Entregados: " + _items_entregados + " <br /> Cantidad de Entregas: " + _entregas + "<br />" + "" + "<br /><br><br></div>"; /*string strMarker = "<div style='width: 250px; height: 185px'><b>" + * "<span style='color:#ff7e00'>es</span>ASP.NET</b><br>" + * " C/ C/ Nombre de Calle, No X <br /> 28031 Madrid, España <br />" + * "Tel: +34 902 00 00 00 <br />Fax: +34 91 000 00 00<br />" + * "Web: <a href='http://www.esASP.net/' class='txtBKM' >www.esASP.net</a>" + * "<br />Email: <a href='mailto:[email protected]' class='txtBKM'>" + * "[email protected]</a><br><br></div>"; */ GInfoWindow window = new GInfoWindow(marker, strMarker, false, GListener.Event.mouseover); GMap.Add(window); GMap.enableHookMouseWheelToZoom = true; //Tipo de mapa a mostrar //GMap.mapType = GMapType.GTypes.Normal; GMapType.GTypes maptype = GMapType.GTypes.Normal; GLatLng latlong = new GLatLng(-0.185631, -78.484490); GMap.setCenter(latlong, 12, maptype); //Moverse con el cursor del teclado GMap.enableGKeyboardHandler = true; }
protected string GMap1_Click(object s, Subgurim.Controles.GAjaxServerEventArgs e) { GMap gmap = new GMap(e.map); // GMarker and GInfoWindow GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, "Cool!!", true); gmap.Add(window); // Movement //gmap.addMovement(1000, e.point + new GLatLng(25, 38)); //gmap.addMovement(1000, e.point); // Polylines if (e.point != e.center) { List <GLatLng> points = new List <GLatLng>(); points.Add(e.center); points.Add(e.point); gmap.Add(new GPolyline(points, Color.Yellow)); } // Controls gmap.Add(new GControl(GControl.extraBuilt.MarkCenter)); gmap.Add(new GControl(GControl.preBuilt.LargeMapControl)); gmap.Add(new GControl(GControl.preBuilt.MapTypeControl)); // Maybe... anything? ;) gmap.enableHookMouseWheelToZoom = false; gmap.mapType = GMapType.GTypes.Satellite; return(gmap.ToString()); }
protected void bt_Buscar_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(tb_Buscar.Text)) { lblLat.Text = ""; lblLng.Text = ""; lb_Buscar.Text = ""; string key = ConfigurationManager.AppSettings.Get("googlemaps.subgurim.net"); GeoCode geocode = GMap.geoCodeRequest(tb_Buscar.Text, key, new GLatLngBounds(new GLatLng(40, 10), new GLatLng(50, 20))); GMap gMap1 = new GMap(); gMap1.getGeoCodeRequest(tb_Buscar.Text, new GLatLngBounds(new GLatLng(40, 10), new GLatLng(50, 20))); if ((null != geocode) && geocode.valid) { lblLat.Text = geocode.Placemark.coordinates.lat.ToString(); lblLng.Text = geocode.Placemark.coordinates.lng.ToString(); lb_Buscar.Text = "Dirección encontrada"; mostrarDireccion(lblLat.Text.Trim(), lblLng.Text.Trim()); } else { lb_Buscar.Text = "No se encontró la dirección"; } } }
protected string GMap1_Click(object s, Subgurim.Controles.GAjaxServerEventArgs e) { GMap gmap = new GMap(e.map); // GMarker and GInfoWindow GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, "Cool!!", true); gmap.Add(window); // Movement //gmap.addMovement(1000, e.point + new GLatLng(25, 38)); //gmap.addMovement(1000, e.point); // Polylines if (e.point != e.center) { List<GLatLng> points = new List<GLatLng>(); points.Add(e.center); points.Add(e.point); gmap.Add(new GPolyline(points, Color.Yellow)); } // Controls gmap.Add(new GControl(GControl.extraBuilt.MarkCenter)); gmap.Add(new GControl(GControl.preBuilt.LargeMapControl)); gmap.Add(new GControl(GControl.preBuilt.MapTypeControl)); // Maybe... anything? ;) gmap.enableHookMouseWheelToZoom = false; gmap.mapType = GMapType.GTypes.Satellite; return gmap.ToString(); }
public PureImage GetTileImageUsingHttp(GMap.NET.GPoint pos, int zoom) { PureImage image = null; TileImageEventArgs args = new TileImageEventArgs(pos, zoom); args.Image = MapHelper.GetImage(type, args.Url); if (args.Image == null) { if (OnNeedTileImage != null) { OnNeedTileImage(image, args); } else { args.Image = Mapserver.GetImage(type, args.Url); if (args.Image != null) { MapHelper.SetImage(type, args.Url, args.Image); } } } if (args.Image != null) { MemoryStream stream = new MemoryStream(args.Image); image = TileImageProxy.FromStream(stream); if (image != null) image.Data = stream; args.Image = null; } return image; }
public GhostMarker(GMap.NET.PointLatLng p) : base(p) { base.Size = new Size(8, 8); Offset = new Point(-4, -4); }
// move current marker with left holding void MainMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) { System.Windows.Point p = e.GetPosition(this); _currentMarker.Position = GMap.FromLocalToLatLng((int)p.X, (int)p.Y); } }
static void Main(string[] args) { String GMapPath = args[0]; var map = GMap.Load(new FileStream(GMapPath, FileMode.Open)); map.Save(new FileStream("export.gps", FileMode.Create)); }
public GMapMarkerImage(GMap.NET.PointLatLng p, Image image) : base(p) { Size = new System.Drawing.Size(image.Width/2, image.Height/2); Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2); this.image = image; Pen = null; OutPen = null; }
public void SetupBasicGMapDisplay(int office_id) { RepositionMap(office_id); GMap.enableHookMouseWheelToZoom = true; GMap.addControl(new GControl(GControl.preBuilt.LargeMapControl)); GMap.addControl(new GControl(GControl.preBuilt.MapTypeControl)); GMap.addControl(new GControl(GControl.preBuilt.GOverviewMapControl)); GMap.addMapType(GMapType.GTypes.Physical); GMap.mapType = GMapType.GTypes.Physical; GMap.resetMarkers(); }
protected void btnBuscarUbicacion_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtBusquedaUbicacion.Text)) { string key = ConfigurationManager.AppSettings.Get("googlemaps.subgurim.net"); GeoCode Informacion = GMap.geoCodeRequest(txtBusquedaUbicacion.Text, key); MapaPrueba.resetInfoWindows(); Marcador = new GMarker(Informacion.Placemark.coordinates); PlantillaMensajeVentana = "<center>" + Informacion.Placemark.address + "</center>"; MuestraUbicacionEnMapa(Marcador.point.lat, Marcador.point.lng, PlantillaMensajeVentana, 17); } }
/// <summary> /// On click marker. Zooms directly to the incident. /// </summary> private void gmap_OnMarkerClick(GMap.NET.WindowsForms.GMapMarker item, MouseEventArgs e) { string id = item.ToolTipText.Split(';')[0]; // get the id from tool tip // compare id values with the incident Combobox for (int i = 0; i < incidentCB.Items.Count; i++) { //id of combobox string id2 = incidentCB.Items[i].ToString().Split(';')[0]; if (id == id2) { incidentCB.SelectedIndex = i; break; } } }
public void AddOfficeToMap(int office_id) { var office = db.Offices.FirstOrDefault(p => p.office_id == office_id); GLatLng latlon = default(GLatLng); GMarker marker = default(GMarker); GInfoWindow window = default(GInfoWindow); string winText = null; winText = "<b>" + office.office_nm + "<br />" + office.street_addrs + "<br />" + office.city_st_zip + "<br />" + office.ph_no + "</b>"; latlon = new GLatLng((double)office.dec_lat_va, (double)office.dec_long_va); marker = new GMarker(latlon); window = new GInfoWindow(marker, winText, false, GListener.Event.click); GMap.addInfoWindow(window); }
// zoo max & center markers private void button13_Click(object sender, RoutedEventArgs e) { GMap.ZoomAndCenterMarkers(null); /* * PointAnimation panMap = new PointAnimation(); * panMap.Duration = TimeSpan.FromSeconds(1); * panMap.From = new Point(MainMap.Position.Lat, MainMap.Position.Lng); * panMap.To = new Point(0, 0); * Storyboard.SetTarget(panMap, MainMap); * Storyboard.SetTargetProperty(panMap, new PropertyPath(GMapControl.MapPointProperty)); * * Storyboard panMapStoryBoard = new Storyboard(); * panMapStoryBoard.Children.Add(panMap); * panMapStoryBoard.Begin(this); */ }
/// <summary> /// Constructor /// </summary> /// <param name="gMapControl"></param> public SharpMapMarker(GMap.NET.WindowsForms.GMapControl gMapControl) : base(GMap.NET.PointLatLng.Zero) { m_gMapControl = gMapControl; myMap = new SharpMap.Map(new System.Drawing.Size(m_gMapControl.Width, m_gMapControl.Height)); m_shapeLayer = new SharpMap.Layers.VectorLayer("SharpMap layer" + Guid.NewGuid()); //m_shapeLayer.Style.Outline = new System.Drawing.Pen(System.Drawing.Color.Green, 1f); m_shapeLayer.Style.EnableOutline = false; m_shapeLayer.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Blue, 1f); //myMap.Center = new SharpMap.Geometries.Point(121.54399, 29.868336); DisableRegionCheck = true; IsHitTestVisible = false; }
public static ArrayList getRecuperaCoordenadas(string pDireccion) { ArrayList myArray = new ArrayList(); GMap GMap1 = new GMap(); string skey = ""; GeoCode geocode; geocode = GMap1.getGeoCodeRequest(pDireccion); myArray.Add(geocode.Placemark.coordinates.lat); myArray.Add(geocode.Placemark.coordinates.lng); return(myArray); }
public GeobaseMapMarker(GMap.NET.WindowsForms.GMapControl gMapControl, string mapFileName) : base(GMap.NET.PointLatLng.Zero) { m_gMapControl = gMapControl; if (!string.IsNullOrEmpty(mapFileName)) { string fileName = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), mapFileName); if (System.IO.File.Exists(fileName)) { Telogis.GeoBase.Repositories.Repository.Default = new Telogis.GeoBase.Repositories.SimpleRepository(fileName); } } myMap = new Telogis.GeoBase.MapCtrl(); DisableRegionCheck = true; IsHitTestVisible = false; }
public void LlenarMapaConClientes(ArrayList clientes, GMap map) { GLatLng ubicacion; GMarker marker; string strMarker; foreach (ZoCliente c in clientes) { ubicacion = new GLatLng(c.Latitud, c.Longitud); //Pone la marca de gota de agua con el nombre de la ubicacion marker = new GMarker(ubicacion); strMarker = "<div style='width: 150px; height: 85px'><b>" + "<span style='color:#ff7e00'></span></b><br>" + " " + c.RazSoc + " <br /> " + c.DirSuc + " <br />" + "</div>"; GInfoWindow window = new GInfoWindow(marker, strMarker, false); map.Add(window); } }
public Map GetMap(GRect segment, int subsample, GMap retval) { retval = IsColor ? (GMap)GetPixelMap( segment, subsample, 0.0D, (retval is GPixmap) ? (GPixmap)retval : null) : (GMap)GetBitmap( segment, subsample, 1, ((retval is GBitmap) ? (GBitmap)retval : null)); return(retval); }
//internal void UpdateCarPosition(PointLatLng pointLatLng, double course) //{ // GPoint pt = GMap.FromLatLngToLocal(pointLatLng); // _car.UpdatePosition(pt.X, pt.Y, course); // GMap.Position = pointLatLng; //} public PointLatLng FromLocalToLatLng(int x, int y) { return(GMap.FromLocalToLatLng(x, y)); }
public void fillbranch(bool isrel, ref string branchmapclass, Model.tab_customers modelCu, DropDownList com_Province, DropDownList com_City, DropDownList DropDownList1, GMap GMap1, Literal Literal1, ref string hideik, ref string hidemn, ref string continue2class, ref string supplierlistcontentikang, ref string supplierlistcontentciming, ref string supplierlistcontentmeinian, Panel Panel14, Panel Panel15, Panel Panel16) { if (branchmapclass != "") { return; } string city = "", supplier = ""; if (com_City.SelectedValue != (string)GetGlobalResourceObject("GResource", "com_CityResource1")) { city = com_City.SelectedValue; } //if (DropDownList1.SelectedValue !=(string)GetGlobalResourceObject("GResource", "DropDownList1Resource1") ) //{ // supplier= DropDownList1.SelectedValue ; //} if (modelCu.disablebranch != "") { if (modelCu.disablebranch.Contains("爱康国宾")) { hideik = "hidden"; } if (modelCu.disablebranch.Contains("美年大健康")) { hidemn = "hidden"; } } //int itemmax = fillbranchmap(GMap1, // Bll.reserveexam.getbranchlist(modelCu,com_Province.SelectedValue,city,supplier), // ref continue2class, ref supplierlistcontentikang, ref supplierlistcontentciming, ref supplierlistcontentmeinian); int itemmax; if (isrel) { itemmax = fillbranchbaidumap(Literal1, Bll.reserveexam.getbranchlistRel(modelCu, com_Province.SelectedValue, city, supplier), ref continue2class, ref supplierlistcontentikang, ref supplierlistcontentciming, ref supplierlistcontentmeinian); } else { itemmax = fillbranchbaidumap(Literal1, Bll.reserveexam.getbranchlist(modelCu, com_Province.SelectedValue, city, supplier), ref continue2class, ref supplierlistcontentikang, ref supplierlistcontentciming, ref supplierlistcontentmeinian); } if (itemmax < 5) { Panel14.Height = itemmax * 80 + 60; Panel15.Height = Panel14.Height; Panel16.Height = Panel14.Height; } else { Panel14.Height = 440; Panel15.Height = Panel14.Height; Panel16.Height = Panel14.Height; } if (supplierlistcontentmeinian == "") { hidemn = "hidden"; } }
private void SetLabelAttributes(ref GMap.NET.WindowsForms.Markers.GMapMarkerCross Marker_In) { // Label Text Font and Size Marker_In.ToolTip.Font = new Font(LabelAttributes.TextFont, LabelAttributes.TextSize, FontStyle.Bold | FontStyle.Regular); Marker_In.ToolTip.Foreground = new SolidBrush(LabelAttributes.TextColor); // Label Border color Marker_In.ToolTip.Stroke = new Pen(new SolidBrush(LabelAttributes.LineColor), LabelAttributes.LineWidth); Marker_In.ToolTip.Stroke.DashStyle = LabelAttributes.LineStyle; // Label background color Marker_In.ToolTip.Fill = Brushes.Transparent; // Symbol color Marker_In.Pen = new Pen(new SolidBrush(LabelAttributes.TargetColor), LabelAttributes.TargetSize); Marker_In.Pen.DashStyle = LabelAttributes.TargetStyle; // Align the text Marker_In.ToolTip.Format.LineAlignment = StringAlignment.Center; Marker_In.ToolTip.Format.Alignment = StringAlignment.Near; }
void MapControl_OnMapTypeChanged(GMap.NET.MapProviders.GMapProvider type) { if (this._currentAction != null && this._currentAction.MapTypeChanged != null) { this._currentAction.MapTypeChanged(type); } }
public void initcitySupplier(bool isrel, ref string branchmapclass, Model.tab_customers modelCu, DropDownList com_Province, DropDownList com_City, DropDownList DropDownList1, GMap GMap1, Literal Literal1, ref string hideik, ref string hidemn, ref string continue2class, ref string supplierlistcontentikang, ref string supplierlistcontentciming, ref string supplierlistcontentmeinian, Panel Panel14, Panel Panel15, Panel Panel16) { initprovincecitydropdown(isrel, modelCu, com_Province, com_City); fillbranch(isrel, ref branchmapclass, modelCu, com_Province, com_City, DropDownList1, GMap1, Literal1, ref hideik, ref hidemn, ref continue2class, ref supplierlistcontentikang, ref supplierlistcontentciming, ref supplierlistcontentmeinian, Panel14, Panel15, Panel16); //try //{ // DataTable dt; // if (isrel) // { // dt = Bll.reserveexam.getexamprovinceRel(modelCu.customerCompany); // } // else // { // dt = Bll.reserveexam.getexamprovince(modelCu.customerCompany); // } // for (int i = 0; i < dt.Rows.Count; i++) // { // com_Province.Items.Add(dt.Rows[i][0].ToString()); // } // int proindex, cityindex; // string province = "", city = ""; // if (modelCu.customerProvince != "") // { // province = modelCu.customerProvince; // } // else if (modelCu.customerCompanyProvince != "") // { // province = modelCu.customerCompanyProvince; // } // if (modelCu.customerCity != "") // { // city = modelCu.customerCity; // } // else if (modelCu.customerCompanyCity != "") // { // city = modelCu.customerCompanyCity; // } // if (province != "") // { // proindex = com_Province.Items.IndexOf(com_Province.Items.FindByText(province)); // if (proindex > 0) // { // com_Province.SelectedIndex = proindex; // if (isrel) // { // com_Province_SelectedIndexChanged(true,modelCu.customerCompany, com_Province, com_City); // } // else // { // com_Province_SelectedIndexChanged(false, modelCu.customerCompany, com_Province, com_City); // } // if (city != "") // { // cityindex = com_City.Items.IndexOf(com_City.Items.FindByText(city)); // if (cityindex > 0) // { // com_City.SelectedIndex = cityindex; // branchmapclass = ""; // fillsupplier(modelCu, com_Province, com_City, DropDownList1); // fillbranch(isrel, ref branchmapclass, modelCu, com_Province, com_City, DropDownList1, GMap1, Literal1, ref hideik, ref hidemn, ref continue2class, ref supplierlistcontentikang, ref supplierlistcontentciming, ref supplierlistcontentmeinian, Panel14, Panel15, Panel16); // } // } // } // } //} //catch (Exception) //{ // Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('数据库连接错误!');</script>"); //} }
public override GMap.NET.PureImage GetTileImage(GMap.NET.GPoint pos, int zoom) { return GetTileImageUsingHttp(pos, zoom); }
public bool PutOffsetToCache(GMap.NET.GPoint pos, int zoom, System.Drawing.Size offset) { bool flag = true; if (this.Created) { try { using (SQLiteConnection connection = new SQLiteConnection()) { connection.ConnectionString = this.ConnectionString; connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (DbCommand command = connection.CreateCommand()) { command.Transaction = transaction; command.CommandText = "INSERT INTO GoogleMapOffsetCache([X], [Y], [Zoom], [OffsetX], [OffsetY] ) VALUES(@x, @y, @zoom, @offsetx, @offsety)"; command.Parameters.Add(new SQLiteParameter("@x", pos.X)); command.Parameters.Add(new SQLiteParameter("@y", pos.Y)); command.Parameters.Add(new SQLiteParameter("@zoom", zoom)); command.Parameters.Add(new SQLiteParameter("@offsetx", offset.Width)); command.Parameters.Add(new SQLiteParameter("@offsety", offset.Height)); command.ExecuteNonQuery(); } //using (DbCommand command2 = connection.CreateCommand()) //{ // command2.Transaction = transaction; // command2.CommandText = "INSERT INTO TilesData(id, Tile) VALUES((SELECT last_insert_rowid()), @p1)"; // command2.Parameters.Add(new SQLiteParameter("@p1", tile.GetBuffer())); // command2.ExecuteNonQuery(); //} transaction.Commit(); } catch (Exception) { transaction.Rollback(); flag = false; } finally { if (transaction != null) { transaction.Dispose(); } } connection.Close(); } } catch (Exception) { flag = false; } } return flag; }
//public static bool ExportMapDataToDB(string sourceFile, string destFile) //{ // bool flag = true; // try // { // if (!File.Exists(destFile)) // { // flag = CreateEmptyDB(destFile); // } // if (!flag) // { // return flag; // } // using (SQLiteConnection connection = new SQLiteConnection()) // { // connection.ConnectionString = string.Format("Data Source=\"{0}\";Page Size=32768;Pooling=True", sourceFile); // connection.Open(); // if (connection.State == ConnectionState.Open) // { // using (SQLiteConnection connection2 = new SQLiteConnection()) // { // connection2.ConnectionString = string.Format("Data Source=\"{0}\";Page Size=32768;Pooling=True", destFile); // connection2.Open(); // if (connection2.State == ConnectionState.Open) // { // using (SQLiteCommand command = new SQLiteCommand(string.Format("ATTACH DATABASE \"{0}\" AS Source", sourceFile), connection2)) // { // command.ExecuteNonQuery(); // } // using (SQLiteTransaction transaction = connection2.BeginTransaction()) // { // try // { // List<long> list = new List<long>(); // using (SQLiteCommand command2 = new SQLiteCommand("SELECT id, X, Y, Zoom, Type FROM Tiles;", connection)) // { // using (SQLiteDataReader reader = command2.ExecuteReader()) // { // while (reader.Read()) // { // long item = reader.GetInt64(0); // using (SQLiteCommand command3 = new SQLiteCommand(string.Format("SELECT id FROM Tiles WHERE X={0} AND Y={1} AND Zoom={2} AND Type={3};", new object[] { reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4) }), connection2)) // { // using (SQLiteDataReader reader2 = command3.ExecuteReader()) // { // if (!reader2.Read()) // { // list.Add(item); // } // } // continue; // } // } // } // } // foreach (long num2 in list) // { // using (SQLiteCommand command4 = new SQLiteCommand(string.Format("INSERT INTO Tiles(X, Y, Zoom, Type) SELECT X, Y, Zoom, Type FROM Source.Tiles WHERE id={0}; INSERT INTO TilesData(id, Tile) Values((SELECT last_insert_rowid()), (SELECT Tile FROM Source.TilesData WHERE id={0}));", num2), connection2)) // { // command4.Transaction = transaction; // command4.ExecuteNonQuery(); // continue; // } // } // list.Clear(); // transaction.Commit(); // } // catch // { // transaction.Rollback(); // flag = false; // } // return flag; // } // } // return flag; // } // } // return flag; // } // } // catch (Exception) // { // flag = false; // } // return flag; //} public System.Drawing.Size? GetOffsetFromCache(GMap.NET.GPoint pos, int zoom) { System.Drawing.Size? ret = null; try { using (SQLiteConnection connection = new SQLiteConnection()) { connection.ConnectionString = this.ConnectionString; connection.Open(); using (DbCommand command = connection.CreateCommand()) { command.CommandText = string.Format(sqlSelect, new object[] { pos.X, pos.Y, zoom}); using (DbDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess)) { if (reader.Read()) { ret = new System.Drawing.Size(reader.GetInt32(0), reader.GetInt32(1)); } reader.Close(); } } connection.Close(); } } catch (Exception) { ret = null; } return ret; }
/// <summary> /// Initialize the map /// </summary> public void InitializeMapData() { // populate map data var db = Sitecore.Context.Database; if (DataSource == null || DataSource.TemplateName != Settings.GoogleMapTemplateName) { Log.Error("Google Maps Module - could not find the data source to display the map", Settings.LoggingOwner); return; } try { // get map settings CurrentMap = new GMap(); CurrentMap.CanvasID = "map_canvas" + ClientID; // EnsureField checks whether a field is present on an item and logs errors Utilities.EnsureField(DataSource, "Latitude", true); Utilities.EnsureField(DataSource, "Longitude", true); CurrentMap.Center = new GLatLng(DataSource.Fields["Latitude"].Value, DataSource.Fields["Longitude"].Value); Utilities.EnsureField(DataSource, "Initial Zoom Level", false); CurrentMap.Zoom = int.Parse(DataSource.Fields["Initial Zoom Level"].Value); Utilities.EnsureField(DataSource, "Width", false); Utilities.EnsureField(DataSource, "Height", false); CurrentMap.Width = int.Parse(DataSource.Fields["Width"].Value); CurrentMap.Height = int.Parse(DataSource.Fields["Height"].Value); Utilities.EnsureField(DataSource, "Map Types", false); CurrentMap.MapTypes = new List <string>(); MultilistField mapTypes = ((MultilistField)DataSource.Fields["Map Types"]); foreach (ID mapTypeId in mapTypes.TargetIDs) { Item mapTypeItem = db.GetItem(mapTypeId); Utilities.EnsureField(mapTypeItem, "Type", true); CurrentMap.MapTypes.Add(mapTypeItem.Fields["Type"].Value); } Utilities.EnsureField(DataSource, "Draggable Cursor", false); CurrentMap.DraggableCursor = DataSource.Fields["Draggable Cursor"].Value; Utilities.EnsureField(DataSource, "Dragging Cursor", false); CurrentMap.DraggingCursor = DataSource.Fields["Dragging Cursor"].Value; int tmpval; Utilities.EnsureField(DataSource, "Min Zoom Level", false); if (int.TryParse(DataSource.Fields["Min Zoom Level"].Value, out tmpval)) { CurrentMap.MinZoomLevel = tmpval; } else { CurrentMap.MinZoomLevel = null; } Utilities.EnsureField(DataSource, "Max Zoom Level", false); if (int.TryParse(DataSource.Fields["Max Zoom Level"].Value, out tmpval)) { CurrentMap.MaxZoomLevel = tmpval; } else { CurrentMap.MaxZoomLevel = null; } Utilities.EnsureField(DataSource, "Enable Double Click Zoom", false); CurrentMap.EnableDoubleClickZoom = ((CheckboxField)DataSource.Fields["Enable Double Click Zoom"]).Checked; Utilities.EnsureField(DataSource, "Enable Dragging", false); CurrentMap.EnableDragging = ((CheckboxField)DataSource.Fields["Enable Dragging"]).Checked; Utilities.EnsureField(DataSource, "Enable Scroll Wheel Zoom", false); CurrentMap.EnableScrollWheelZoom = ((CheckboxField)DataSource.Fields["Enable Scroll Wheel Zoom"]).Checked; Utilities.EnsureField(DataSource, "Enable Keyboard Functionality", false); CurrentMap.EnableKeyboardFunctionality = ((CheckboxField)DataSource.Fields["Enable Keyboard Functionality"]).Checked; Utilities.EnsureField(DataSource, "Disable All Default UI Elements", false); CurrentMap.DisableAllDefaultUIElements = ((CheckboxField)DataSource.Fields["Disable All Default UI Elements"]).Checked; Utilities.EnsureField(DataSource, "Enable Overview", false); CurrentMap.EnableOverview = ((CheckboxField)DataSource.Fields["Enable Overview"]).Checked; Utilities.EnsureField(DataSource, "Enable Pan Control", false); CurrentMap.EnablePanControl = ((CheckboxField)DataSource.Fields["Enable Pan Control"]).Checked; Utilities.EnsureField(DataSource, "Enable Scale Control", false); CurrentMap.EnableScaleControl = ((CheckboxField)DataSource.Fields["Enable Scale Control"]).Checked; Utilities.EnsureField(DataSource, "Enable Street View Control", false); CurrentMap.EnableStreetViewControl = ((CheckboxField)DataSource.Fields["Enable Street View Control"]).Checked; Utilities.EnsureField(DataSource, "Enable Zoom Control", false); CurrentMap.EnableZoomControl = ((CheckboxField)DataSource.Fields["Enable Zoom Control"]).Checked; // get all markers CurrentMap.Markers = new List <GMarker>(); CurrentMap.Lines = new List <GLine>(); CurrentMap.Polygons = new List <GPolygon>(); if (DataSource.HasChildren) { foreach (Item childElement in DataSource.Children) { if (childElement.TemplateName == Settings.LocationTemplateName) { GMarker marker = new GMarker(); Utilities.EnsureField(childElement, "Latitude", true); Utilities.EnsureField(childElement, "Longitude", true); marker.Position = new GLatLng(childElement.Fields["Latitude"].Value, childElement.Fields["Longitude"].Value); marker.Title = childElement.Name; Utilities.EnsureField(childElement, "Text", false); marker.InfoWindow = childElement.Fields["Text"].Value; // check if marker has a custom icon if (childElement.Fields["Custom Icon"] != null && childElement.Fields["Custom Icon"].HasValue && ((ReferenceField)childElement.Fields["Custom Icon"]).TargetItem != null) { Item customIcon = ((ReferenceField)childElement.Fields["Custom Icon"]).TargetItem; GIcon icon = new GIcon(); Utilities.EnsureField(customIcon, "Image", true); icon.ImageURL = Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(((Sitecore.Data.Fields.ImageField)customIcon.Fields["Image"]).MediaItem)); icon.ImageDimensions = Utilities.GetMediaItemSize((Sitecore.Data.Fields.ImageField)customIcon.Fields["Image"]); Utilities.EnsureField(customIcon, "Anchor", false); icon.Anchor = Utilities.StringToPoint(customIcon.Fields["Anchor"].Value); Utilities.EnsureField(customIcon, "Shadow Image", false); if (customIcon.Fields["Shadow Image"].HasValue && ((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]).MediaItem != null) { icon.ShadowURL = Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]).MediaItem)); icon.ShadowDimensions = Utilities.GetMediaItemSize((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]); Utilities.EnsureField(customIcon, "Shadow Anchor", false); icon.ShadowAnchor = Utilities.StringToPoint(customIcon.Fields["Shadow Anchor"].Value); } Utilities.EnsureField(customIcon, "Clickable Polygon", false); if (customIcon.Fields["Clickable Polygon"].HasValue && !string.IsNullOrEmpty(customIcon.Fields["Clickable Polygon"].Value)) { icon.ClickablePolygon = customIcon.Fields["Clickable Polygon"].Value; } marker.CustomIcon = icon; } CurrentMap.Markers.Add(marker); } else if (childElement.TemplateName == Settings.LineTemplateName) { GLine line = new GLine(); Utilities.EnsureField(childElement, "Stroke Color", false); line.StrokeColor = childElement.Fields["Stroke Color"].Value; Utilities.EnsureField(childElement, "Stroke Opacity", false); line.StrokeOpacity = Utilities.EnsureOpacity(childElement.Fields["Stroke Opacity"].Value); Utilities.EnsureField(childElement, "Stroke Weight", false); line.StrokeWeight = Utilities.EnsureWeight(childElement.Fields["Stroke Weight"].Value); Utilities.EnsureField(childElement, "Points", false); var points = ((MultilistField)childElement.Fields["Points"]).Items; line.Points = Utilities.ArrayToLatLngList(points); CurrentMap.Lines.Add(line); } else if (childElement.TemplateName == Settings.PolygonTemplateName) { GPolygon poly = new GPolygon(); Utilities.EnsureField(childElement, "Stroke Color", false); poly.StrokeColor = childElement.Fields["Stroke Color"].Value; Utilities.EnsureField(childElement, "Stroke Opacity", false); poly.StrokeOpacity = Utilities.EnsureOpacity(childElement.Fields["Stroke Opacity"].Value); Utilities.EnsureField(childElement, "Stroke Weight", false); poly.StrokeWeight = Utilities.EnsureWeight(childElement.Fields["Stroke Weight"].Value); Utilities.EnsureField(childElement, "Points", false); var points = ((MultilistField)childElement.Fields["Points"]).Items; poly.Points = Utilities.ArrayToLatLngList(points); Utilities.EnsureField(childElement, "Fill Color", false); poly.FillColor = childElement.Fields["Fill Color"].Value; Utilities.EnsureField(childElement, "Fill Opacity", false); poly.FillOpacity = Utilities.EnsureOpacity(childElement.Fields["Fill Opacity"].Value); Utilities.EnsureField(childElement, "Is Clickable", false); poly.Clickable = ((CheckboxField)childElement.Fields["Is Clickable"]).Checked; Utilities.EnsureField(childElement, "Text", false); poly.InfoWindow = childElement.Fields["Text"].Value; CurrentMap.Polygons.Add(poly); } } } } catch (FieldValidationException) { // this has been logged already - nothing to do here. } catch (Exception ex) { Log.Error("Google Maps Module - could not initialize the map", ex, Settings.LoggingOwner); } }
public bool PutOffsetToCache(GMap.NET.GPoint pos, int zoom, System.Drawing.Size offset) { bool ret = true; { if (Initialize()) { try { lock (cmdInsert) { cmdInsert.Parameters["@x"].Value = pos.X; cmdInsert.Parameters["@y"].Value = pos.Y; cmdInsert.Parameters["@zoom"].Value = zoom; cmdInsert.Parameters["@offsetx"].Value = offset.Width; cmdInsert.Parameters["@offsety"].Value = offset.Height; cmdInsert.ExecuteNonQuery(); } } catch (Exception) { ret = false; Dispose(); } } } return ret; }
protected void bt_Buscar_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TextBox1.Text)) { string Key = System.Configuration.ConfigurationManager.AppSettings.Get("googlemaps.subgurim.net"); GeoCode geocode = GMap.geoCodeRequest(TextBox1.Text, Key); //GeoCode geocode = GMap1.getGeoCodeRequest(TextBox1.Text); System.Text.StringBuilder sb = new System.Text.StringBuilder(); if ((null != geocode) && geocode.valid) { sb.Append("<ul>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.name"); sb.Append("</i>: "); sb.Append(geocode.name); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Status.code"); sb.Append("</i>: "); sb.Append(geocode.Status.code); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Status.request"); sb.Append("</i>: "); sb.Append(geocode.Status.request); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.address"); sb.Append("</i>: "); sb.Append(geocode.Placemark.address); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.accuracy"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.accuracy); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.Country.CountryNameCode"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.Country.CountryNameCode); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName"); sb.Append("</i>: "); sb.Append(geocode.Placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName); sb.Append("</li>"); sb.Append("<li>"); sb.Append("<i>"); sb.Append("geocode.Placemark.coordinates"); sb.Append("</i>: "); sb.Append(geocode.Placemark.coordinates.ToString()); sb.Append("</li>"); sb.Append("</ul>"); } else { sb.Append("Ubicación no encontrada"); } Label1.Text = sb.ToString(); } }
public void AddSitesToMap(int wsc_id, int office_id, int trip_id) { int rowCount = 0; double lat = 0; double latAvg = 0; double latMin = 0; double latMax = 0; double latPrev = 0; double lng = 0; double lngAvg = 0; double lngMin = 0; double lngMax = 0; double lngPrev = 0; int MapZoomLevel = 0; string site_tp_cd = null; GLatLng latlon = default(GLatLng); GMarker marker = default(GMarker); GInfoWindow window = default(GInfoWindow); string winText = ""; string trip_nm = ""; int i = 0; var SiteList = db.vFieldTripSites.Where(p => p.trip_id == trip_id).ToList(); foreach (var site in SiteList) { string site_no = site.site_no.Trim(); if ((!object.ReferenceEquals(site.dec_lat_va, DBNull.Value))) { lat = (double)site.dec_lat_va; } if ((!object.ReferenceEquals(site.dec_long_va, DBNull.Value))) { lng = (double)site.dec_long_va; } if (lat == 0 | lng == 0) { i += 1; } else { site_tp_cd = site.site_tp_cd; trip_nm = site.trip_full_nm; if (lat != latPrev & lng != lngPrev) { winText = ""; } else { winText = winText + "<hr />"; } winText = winText + "<b>" + site_no + " " + site.station_nm + "<br />" + trip_nm + "</b><br /><br />" + "<a href=\"https://sims.water.usgs.gov/SIMS/StationInfo.aspx?site_id=" + site.site_id.ToString() + "\" target=\"_blank\">SIMS Station Information Page</a><br />" + "<a href=\"http://waterdata.usgs.gov/nwis/nwisman/?site_no=" + site_no + "\" target=\"_blank\">NWIS Web</a>"; latAvg = latAvg + lat; lngAvg = lngAvg + lng; if (i == 0) { latMin = lat; latMax = lat; lngMin = lng; lngMax = lng; } else { if (lat < latMin) { latMin = lat; } if (lat > latMax) { latMax = lat; } if (lng < lngMin) { lngMin = lng; } if (lng > lngMax) { lngMax = lng; } } latlon = new GLatLng(lat, lng); marker = new GMarker(latlon, GetMarkerOpts()); window = new GInfoWindow(marker, winText, false, GListener.Event.click); GMap.addInfoWindow(window); latPrev = lat; lngPrev = lng; i += 1; } } rowCount = SiteList.Count(); if (rowCount == 0) { SetupBasicGMapDisplay(wsc_id); } else { //zoom/center map based on markers latAvg = (latAvg / i); lngAvg = (lngAvg / i); MapZoomLevel = GetMapZoomLevel(latMin, latMax, lngMin, lngMax); GMap.setCenter(new GLatLng(latAvg, lngAvg), MapZoomLevel); } lblResultsCount.Text = "Sites returned: " + rowCount.ToString(); }
void gMapControl1_OnPositionChanged(GMap.NET.PointLatLng point) { OnPropertyChanged("Center"); }
// empty tile displayed void MainMap_OnEmptyTileError(int zoom, GMap.NET.Point pos) { MessageBox.Show("OnEmptyTileError, Zoom: " + zoom + ", " + pos.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
void Markers_CollectionChanged(object sender, GMap.NET.ObjectModel.NotifyCollectionChangedEventArgs e) { refreshRoute(); }
public override bool Save(Stream stream, GMap.NET.PureImage image) { WindowsFormsImage ret = image as WindowsFormsImage; bool ok = true; if(ret.Img != null) { // try png try { ret.Img.Save(stream, System.Drawing.Imaging.ImageFormat.Png); } catch { // try jpeg try { stream.Seek(0, SeekOrigin.Begin); ret.Img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); } catch { ok = false; } } } else { ok = false; } return ok; }
private void mapControl_OnPositionChanged(GMap.NET.PointLatLng point) { if (PositionChanged != null) { PositionChanged.Invoke(mapControl, EventArgs.Empty); } }
//本函数为谷歌地图 public int fillbranchmap(GMap GMap1, DataTable dt, ref string continue2class, ref string supplierlistcontentikang, ref string supplierlistcontentciming, ref string supplierlistcontentmeinian) { GMap1.reset(); GMap1.Add(new GControl(GControl.preBuilt.GOverviewMapControl)); GMap1.Add(new GControl(GControl.preBuilt.LargeMapControl)); GIcon baseIcon = new GIcon(); baseIcon.shadow = "http://www.google.cn/mapfiles/shadow50.png"; baseIcon.iconSize = new GSize(20, 34); baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); GIcon letteredIcon; GMarker marker; GInfoWindow window; double lat, lng, clat = 0.0, clng = 0.0; int index = 0; string letter, lilist = "", ballooncontent; supplierlistcontentikang = ""; supplierlistcontentciming = ""; supplierlistcontentmeinian = ""; int itemik = 0, itemcm = 0, itemmn = 0; foreach (DataRow dr in dt.Rows) { letter = ((char)((int)'A' + index++)).ToString(); letteredIcon = new GIcon(baseIcon); letteredIcon.image = "http://www.google.cn/mapfiles/marker" + letter + ".png"; lat = Convert.ToDouble(dr["lat"]); lng = Convert.ToDouble(dr["lng"]); clat += lat; clng += lng; marker = new GMarker(new GLatLng(lat, lng), letteredIcon); string sgm = "http://ditu.google.cn/maps?q=" + Server.UrlEncode(Server.UrlEncode(dr["branch"].ToString())) + "&hl=zh-CN&ie=UTF8" + "&ll=" + lat + "," + lng + "&hq=" + Server.UrlEncode(Server.UrlEncode(dr["address"].ToString())) + "&z=15"; //string sgm = "http://ditu.google.cn/maps?q=" + dr["branch"].ToString() + "&hl=zh-CN&ie=UTF8" //+ "&ll=" + lat + "," + lng + "&hq=" + dr["address"].ToString() + "&z=15"; ballooncontent = "<center><b>" + dr["supplier"].ToString() + "</b><br />" + "<A href='javascript:void(window.open(\"" + sgm + "\",\"_blank\"));'>" + dr["branch"].ToString() + "</A><br />" + "</center>"; window = new GInfoWindow(marker, ballooncontent, false); GMap1.Add(window); if (dt.Rows.Count == 1) { continue2class = ""; lilist = fillsupplierlist(index, letteredIcon.image, dr["supplier"].ToString(), dr["branch"].ToString(), dr["address"].ToString(), dr["id"].ToString(), true) + "\n\n"; } else { lilist = fillsupplierlist(index, letteredIcon.image, dr["supplier"].ToString(), dr["branch"].ToString(), dr["address"].ToString(), dr["id"].ToString(), false) + "\n\n"; } if (dr["supplier"].ToString() == "爱康国宾") { supplierlistcontentikang += lilist; itemik++; } else if (dr["supplier"].ToString() == "美年大健康") { supplierlistcontentmeinian += lilist; itemmn++; } else //if (dr["supplier"].ToString() == "慈铭体检") { supplierlistcontentciming += lilist; itemcm++; } } clat /= dt.Rows.Count; clng /= dt.Rows.Count; GMap1.enableHookMouseWheelToZoom = true; GMap1.setCenter(new GLatLng(clat, clng), 12); int itemmax = Math.Max(itemik, Math.Max(itemmn, itemcm)); return(itemmax); }
public GMapUserControl() { InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { return; } cmbMapType.Items.Add(GMapProviders.GoogleMap); cmbMapType.Items.Add(GMapProviders.GoogleTerrainMap); cmbMapType.Items.Add(GMapProviders.GoogleSatelliteMap); cmbMapType.Items.Add(GMapProviders.BingMap); cmbMapType.Items.Add(GMapProviders.BingHybridMap); cmbMapType.Items.Add(GMapProviders.BingSatelliteMap); //cmbMapType.Items.Add(GMapProviders.YahooMap); //cmbMapType.Items.Add(GMapProviders.YahooHybridMap); //cmbMapType.Items.Add(GMapProviders.YahooSatelliteMap); //cmbMapType.Items.Add(GMapProviders.OviMap); //cmbMapType.Items.Add(GMapProviders.OviHybridMap); //cmbMapType.Items.Add(GMapProviders.OviSatelliteMap); //cmbMapType.Items.Add(GMapProviders.NearMap); //cmbMapType.Items.Add(GMapProviders.NearHybridMap); //cmbMapType.Items.Add(GMapProviders.NearSatelliteMap); // set cache mode only if no internet avaible if (!Stuff.PingNetwork("pingtest.com")) { GMap.Manager.Mode = AccessMode.CacheOnly; MessageBox.Show("No internet connection available, going to CacheOnly mode.", "GMap.NET - Demo.WindowsPresentation", MessageBoxButton.OK, MessageBoxImage.Warning); } //default config map GMap.MapProvider = GMapProviders.GoogleMap; //this.ScaleMode = ScaleModes.Dynamic; GMap.ShowCenter = false; GMap.IgnoreMarkerOnMouseWheel = true; GMap.MouseWheelZoomType = MouseWheelZoomType.ViewCenter; // map events GMap.Loaded += MainMap_Loaded; GMap.OnPositionChanged += MainMap_OnCurrentPositionChanged; GMap.OnTileLoadStart += MainMap_OnTileLoadStart; GMap.OnMapTypeChanged += MainMap_OnMapTypeChanged; GMap.MouseMove += MainMap_MouseMove; GMap.MouseLeftButtonDown += MainMap_MouseLeftButtonDown; GMap.MouseEnter += MainMap_MouseEnter; GMap.OnMapZoomChanged += MainMap_ZoomChanged; // set current marker _currentMarker = new GMapMarker(GMap.Position); _currentMarkerUI = new CustomMarkerRed(GMap, _currentMarker, "custom position marker"); _currentMarkerUI.Visibility = Visibility.Hidden; _currentMarker.ZIndex = int.MaxValue; GMap.Markers.Add(_currentMarker); _route.MouseWheel += (s, e) => { GMap.RaiseEvent(e); }; //routing event to GMap under car image GMap.Position = new PointLatLng(40.754910, -73.994100); //Time Square, NYC }
void MapControl_OnPositionChanged(GMap.NET.PointLatLng point) { if (this._currentAction != null && this._currentAction.PositionChanged != null) { this._currentAction.PositionChanged(point); } }
public override GMap.NET.PureImage GetTileImage(GMap.NET.GPoint pos, int zoom) { PureImage image=GetTileImageUsingHttp(pos, zoom); if(image==null) image=base.GetTileImage(pos,zoom); return image; }
void MainMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { System.Windows.Point p = e.GetPosition(GMap); _currentMarker.Position = GMap.FromLocalToLatLng((int)p.X, (int)p.Y); }
void Overlays_CollectionChanged(object sender, GMap.NET.ObjectModel.NotifyCollectionChangedEventArgs e) { }
/* * private void SetMapLocation() * { * if (GMap == null) return; * * var location = Map.Tag as LatLng; * if (location == null && _userLocation == null) return; * * // Calculate the map position and zoom/size * CameraUpdate cameraUpdate = null; * if (_userLocation == null) * cameraUpdate = CameraUpdateFactory.NewLatLngZoom(location, Constants.DefaultResponseMapZoom); * else if (location == null) * cameraUpdate = CameraUpdateFactory.NewLatLngZoom(_userLocation, Constants.DefaultResponseMapZoom); * else * { * var latDelta = Math.Abs(location.Latitude - _userLocation.Latitude); * var longDelta = Math.Abs(location.Longitude - _userLocation.Longitude); * var minLat = Math.Min(location.Latitude, _userLocation.Latitude) - latDelta / 4; * var maxLat = Math.Max(location.Latitude, _userLocation.Latitude) + latDelta / 4; * var minLong = Math.Min(location.Longitude, _userLocation.Longitude) - longDelta / 4; * var maxLong = Math.Max(location.Longitude, _userLocation.Longitude) + longDelta / 4; * * LatLngBounds.Builder builder = new LatLngBounds.Builder(); * builder.Include(new LatLng(minLat, minLong)); * builder.Include(new LatLng(maxLat, maxLong)); * // shouldn't need to include these but we'll include them just in case * builder.Include(new LatLng(location.Latitude, location.Longitude)); * builder.Include(new LatLng(_userLocation.Latitude, _userLocation.Longitude)); * LatLngBounds bounds = builder.Build(); * cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 0); * } * * // Set the map position * GMap.MoveCamera(cameraUpdate); * * // Add a markers * if (location != null) * { * var markerOptions = new MarkerOptions(); * markerOptions.SetPosition(location); * if (_colorHue > -1) * { * var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(_colorHue); * markerOptions.SetIcon(bmDescriptor); * } * GMap.AddMarker(markerOptions); * } * if (_userLocation != null) * { * var markerOptions0 = new MarkerOptions(); * markerOptions0.SetPosition(_userLocation); * markerOptions0.SetIcon(UserLocationIcon); * markerOptions0.Anchor(0.5f, 0.5f); * GMap.AddMarker(markerOptions0); * } * * // Set the map type back to normal. * GMap.MapType = GoogleMap.MapTypeNormal; * } */ private async Task DrawMapAsync(bool moveMap = true) { if (GMap == null) { return; } if (_eventLocation == null && _currentUserLocation == null) { return; } // Set callback to detect when map has finished loading // _activity.RunOnUiThread(() => { GMap.SetOnMapLoadedCallback(new MapLoadedCallback(Map.Id)); }); await Task.Run(() => { // Calculate the map position and zoom/size CameraUpdate cameraUpdate = null; if (moveMap) { if (_currentUserLocation == null) { // Only event location available cameraUpdate = CameraUpdateFactory.NewLatLngZoom(_eventLocation, Constants.DefaultResponseMapZoom); } else if (_eventLocation == null) { // Only user location available cameraUpdate = CameraUpdateFactory.NewLatLngZoom(_currentUserLocation, Constants.DefaultResponseMapZoom); } else { // Both locations available // get deltas between those locations var latDelta = Math.Abs(_eventLocation.Latitude - _currentUserLocation.Latitude); var longDelta = Math.Abs(_eventLocation.Longitude - _currentUserLocation.Longitude); // get the boundaries of the map var minLat = Math.Min(_eventLocation.Latitude, _currentUserLocation.Latitude) - latDelta / 4; var maxLat = Math.Max(_eventLocation.Latitude, _currentUserLocation.Latitude) + latDelta / 4; var minLong = Math.Min(_eventLocation.Longitude, _currentUserLocation.Longitude) - longDelta / 4; var maxLong = Math.Max(_eventLocation.Longitude, _currentUserLocation.Longitude) + longDelta / 4; LatLngBounds.Builder builder = new LatLngBounds.Builder(); builder.Include(new LatLng(minLat, minLong)); builder.Include(new LatLng(maxLat, maxLong)); // shouldn't need to include these but we'll include them just in case LatLngBounds bounds = builder.Build(); cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 0); } // Set the map position _activity.RunOnUiThread(() => { GMap.MoveCamera(cameraUpdate); }); } _activity.RunOnUiThread(() => { // Add a markers if (_eventLocation != null) { if (EventLocationMarker == null) { var markerOptions = new MarkerOptions(); markerOptions.SetPosition(_eventLocation); if (_colorHue > -1) { var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(_colorHue); markerOptions.SetIcon(bmDescriptor); } EventLocationMarker = GMap.AddMarker(markerOptions); } else { var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(_colorHue); EventLocationMarker.SetIcon(bmDescriptor); EventLocationMarker.Position = _eventLocation; } } if (_currentUserLocation != null) { if (UserLocationMarker == null) { var markerOptions0 = new MarkerOptions(); markerOptions0.SetPosition(_currentUserLocation); markerOptions0.SetIcon(UserLocationIcon); markerOptions0.Anchor(0.5f, 0.5f); UserLocationMarker = GMap.AddMarker(markerOptions0); } else { UserLocationMarker.Position = _currentUserLocation; } } Map.OnResume(); // Map.OnEnterAmbient(null); }); }); // Set the map type back to normal. _activity.RunOnUiThread(() => { GMap.MapType = GoogleMap.MapTypeNormal; }); }
protected void GridViewEvents_OnRowCommand(object sender, GridViewCommandEventArgs e) { //// Only handle our custom commands here! if (e.CommandName.Equals("Handle") || e.CommandName.Equals("Position") || e.CommandName.Equals("DownloadRecording")) { int index = Convert.ToInt32(e.CommandArgument); GridViewRow gvRow = ((GridView)sender).Rows[index]; Int32 eventID = (Int32)GridViewEvents.DataKeys[index].Value; using (braceletEntities context = new braceletEntities()) { switch (e.CommandName) { case "Handle": Event ev = context.Events.Where(o => o.ID == eventID).First(); ev.Status = (byte)CommonNames.EventStatus.Handled; ev.Note = ((TextBox)gvRow.FindControl("TextBoxHandle")).Text; context.SaveChanges(); GridViewEvents.DataBind(); GridViewPanel.Update(); break; case "Position": Event evSelected = context.Events.Where(o => o.ID == eventID).First(); GMapHolder.Visible = true; // Set selected row GridView gv = (GridView)sender; gv.SelectedIndex = index; // Add GUI controls GMap.addGMapUI(new GMapUI()); // Set center point if (evSelected.PositionLatitude != null && evSelected.PositionLongitude != null) { GMap.setCenter(new GLatLng(evSelected.PositionLatitude.Value, evSelected.PositionLongitude.Value)); } // Set zoom level GMap.GZoom = 15; // Add center marker GMap.resetMarkers(); if (evSelected.PositionLatitude != null && evSelected.PositionLongitude != null) { GMap.addGMarker(new GMarker(new GLatLng(evSelected.PositionLatitude.Value, evSelected.PositionLongitude.Value))); } break; case "DownloadRecording": if (HttpContext.Current.User.IsInRole("Administrator")) { Recording rec = context.Recordings.Where(o => o.EventID == eventID).FirstOrDefault(); if (rec != null) { FileStream fStream = null; try { String fileName = "C:\\BraceletRecordings\\" + rec.FileName; HttpResponse r = HttpContext.Current.Response; Response.ContentType = "audio/mpeg"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + rec.FileName); fStream = new FileStream(fileName, FileMode.Open); fStream.CopyTo(Response.OutputStream); Response.End(); } catch (IOException ex) { throw new IOException("Cannot find the selected recording.", ex); } finally { // Always close the fileStream if (fStream != null) { fStream.Close(); } } } } break; default: break; } } } // End of If(e.commandName.Equals("..") || ...) }
void MainMap_MouseEnter(object sender, MouseEventArgs e) { GMap.Focus(); }
public void RepositionMap(int office_id) { //Kept as a list only to retain legacy code for looping through all the offices in a WSC and finding the average lat/long var office = db.Offices.Where(p => p.office_id == office_id).ToList(); double lat = 0; double latAvg = 0; double latMin = 0; double latMax = 0; double lng = 0; double lngAvg = 0; double lngMin = 0; double lngMax = 0; int MapZoomLevel = 0; int i = 0; foreach (var o in office) { lat = (double)o.dec_lat_va; lng = (double)o.dec_long_va; latAvg = latAvg + lat; lngAvg = lngAvg + lng; if (i == 0) { latMin = lat; latMax = lat; lngMin = lng; lngMax = lng; } else { if (lat < latMin) { latMin = lat; } if (lat > latMax) { latMax = lat; } if (lng < lngMin) { lngMin = lng; } if (lng > lngMax) { lngMax = lng; } } i += 1; } latAvg = (latAvg / i); lngAvg = (lngAvg / i); if (office_id > 0) { MapZoomLevel = 7; } else { MapZoomLevel = GetMapZoomLevel(latMin, latMax, lngMin, lngMax); } GMap.setCenter(new GLatLng(latAvg, lngAvg), MapZoomLevel); }
public ActionResult LoadMap(GMap GMap1) { GMap1.Height = 450; GMap1.Width = 800; GMap1.enableDragging = true; GMap1.Language = "es"; GMap1.enableHookMouseWheelToZoom = true; GMap1.enableGKeyboardHandler = true; GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl)); GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl3D)); GMap1.addControl(new GControl(new CarouselMapTypeControl())); GMap1.setCenter(new GLatLng(18.8, -70.2), 8); //Marker Santo Domingo GMarker markerStoDgo = new GMarker(new GLatLng(18.5016629749131, -69.796600313872)); GInfoWindowOptions optionsStoDgo = new GInfoWindowOptions("Detalles Estadisticos de Santo Domingo", @"<div style='margin-top:60px'> <table> <tr> <td style='width:450px'><b>Educacion</b></td> <td style='width:450px'><b>Vivienda</b></td> <td style='width:450px'><b>Empleo</b></td> <td style='width:450px'><b>Salud</b></td> <td style='width:450px'><b>Pobreza</b></td> <td style='width:450px'><b>Poblacion</b></td> </tr> <tr> <td style='width:450px'><a href='Home/Add/detalles.cshtml?provincia=SantoDomingo&tabla=Vacunacion'>a</a></td> <td style='width:450px'><a href='http://google.com'>b</a></td> <td style='width:450px'><a href='http://google.com'>c</a></td> <td style='width:450px'><a href='http://google.com'>e</a></td> <td style='width:450px'><a href='http://google.com'>f</a></td> <td style='width:450px'><a href='http://google.com'>g</a></td> </tr> </table> </div>"); GInfoWindow windowStoDgo = new GInfoWindow(markerStoDgo, "Santo Domingo", optionsStoDgo); GMap1.addInfoWindow(windowStoDgo); //GMarker markerStoDgo = new GMarker(new GLatLng(18.5016629749131, -69.796600313872)); //GInfoWindow windowStoDgo = new GInfoWindow(markerStoDgo, "<center><a href='Santo Domingo'>Prueba<a></center>", true); //GMap1.addInfoWindow(windowStoDgo); ////Marker Samana //GMarker markerSamana = new GMarker(new GLatLng(19.2449631444, -69.4505309779197)); //GInfoWindow windowSamana = new GInfoWindow(markerSamana, "<center><a href='Samana'>Prueba<a></center>", true); //GMap1.addInfoWindow(windowSamana); ////Marker La Romana //GMarker markerRomana = new GMarker(new GLatLng(18.5016629749131, -68.8957214076072)); //GInfoWindow windowRomana = new GInfoWindow(markerRomana, "<center><a href='Romana'>Prueba<a></center>", true); //GMap1.addInfoWindow(windowRomana); ////Marker La San Cristobal //GMarker markerSanCris = new GMarker(new GLatLng(18.5381238176514, -70.1976012904197)); //GInfoWindow windowsSanCris = new GInfoWindow(markerSanCris, "<center><a href='SanCristobal'>Prueba<a></center>", true); //GMap1.addInfoWindow(windowsSanCris); ////Marker La San Barahona //GMarker markerBarahona = new GMarker(new GLatLng(18.136629600166, -71.2193298060447)); //GInfoWindow windowsBarahona = new GInfoWindow(markerBarahona, "<center><a href='Barahona'>Prueba<a></center>", true); //GMap1.addInfoWindow(windowsBarahona); return View(); }
bool CacheTiles(ref MapType[] types, int zoom, GMap.NET.Point p) { foreach(MapType type in types) { Exception ex; PureImage img = GMaps.Instance.GetImageFrom(type, p, zoom, out ex); if(img != null) { img.Dispose(); img = null; } else { return false; } } return true; }
/* * private void SetMapLocation() * { * if (GMap == null) return; * * var location = Map.Tag as LatLng; * if (location == null && _userLocation == null) return; * * // Calculate the map position and zoom/size * CameraUpdate cameraUpdate = null; * if (_userLocation == null) * cameraUpdate = CameraUpdateFactory.NewLatLngZoom(location, Constants.DefaultResponseMapZoom); * else if (location == null) * cameraUpdate = CameraUpdateFactory.NewLatLngZoom(_userLocation, Constants.DefaultResponseMapZoom); * else * { * var latDelta = Math.Abs(location.Latitude - _userLocation.Latitude); * var longDelta = Math.Abs(location.Longitude - _userLocation.Longitude); * var minLat = Math.Min(location.Latitude, _userLocation.Latitude) - latDelta / 4; * var maxLat = Math.Max(location.Latitude, _userLocation.Latitude) + latDelta / 4; * var minLong = Math.Min(location.Longitude, _userLocation.Longitude) - longDelta / 4; * var maxLong = Math.Max(location.Longitude, _userLocation.Longitude) + longDelta / 4; * * LatLngBounds.Builder builder = new LatLngBounds.Builder(); * builder.Include(new LatLng(minLat, minLong)); * builder.Include(new LatLng(maxLat, maxLong)); * // shouldn't need to include these but we'll include them just in case * builder.Include(new LatLng(location.Latitude, location.Longitude)); * builder.Include(new LatLng(_userLocation.Latitude, _userLocation.Longitude)); * LatLngBounds bounds = builder.Build(); * cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 0); * } * * // Set the map position * GMap.MoveCamera(cameraUpdate); * * // Add a markers * if (location != null) * { * var markerOptions = new MarkerOptions(); * markerOptions.SetPosition(location); * if (_colorHue > -1) * { * var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(_colorHue); * markerOptions.SetIcon(bmDescriptor); * } * GMap.AddMarker(markerOptions); * } * if (_userLocation != null) * { * var markerOptions0 = new MarkerOptions(); * markerOptions0.SetPosition(_userLocation); * markerOptions0.SetIcon(UserLocationIcon); * markerOptions0.Anchor(0.5f, 0.5f); * GMap.AddMarker(markerOptions0); * } * * // Set the map type back to normal. * GMap.MapType = GoogleMap.MapTypeNormal; * } */ private void DrawMap(bool moveMap = true) { if (GMap == null) { return; } if (_eventLocation == null && _userLocation == null) { return; } // Calculate the map position and zoom/size CameraUpdate cameraUpdate = null; if (moveMap) { if (_userLocation == null) { cameraUpdate = CameraUpdateFactory.NewLatLngZoom(_eventLocation, Constants.DefaultResponseMapZoom); } else if (_eventLocation == null) { cameraUpdate = CameraUpdateFactory.NewLatLngZoom(_userLocation, Constants.DefaultResponseMapZoom); } else { _latDelta = Math.Abs(_eventLocation.Latitude - _userLocation.Latitude); _longDelta = Math.Abs(_eventLocation.Longitude - _userLocation.Longitude); var minLat = Math.Min(_eventLocation.Latitude, _userLocation.Latitude) - _latDelta / 4; var maxLat = Math.Max(_eventLocation.Latitude, _userLocation.Latitude) + _latDelta / 4; var minLong = Math.Min(_eventLocation.Longitude, _userLocation.Longitude) - _longDelta / 4; var maxLong = Math.Max(_eventLocation.Longitude, _userLocation.Longitude) + _longDelta / 4; LatLngBounds.Builder builder = new LatLngBounds.Builder(); builder.Include(new LatLng(minLat, minLong)); builder.Include(new LatLng(maxLat, maxLong)); // shouldn't need to include these but we'll include them just in case builder.Include(new LatLng(_eventLocation.Latitude, _eventLocation.Longitude)); builder.Include(new LatLng(_userLocation.Latitude, _userLocation.Longitude)); LatLngBounds bounds = builder.Build(); cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 0); } // Set the map position GMap.MoveCamera(cameraUpdate); } // Add a markers if (_eventLocation != null) { if (_eventLocationMarker == null) { var markerOptions = new MarkerOptions(); markerOptions.SetPosition(_eventLocation); if (_colorHue > -1) { var bmDescriptor = BitmapDescriptorFactory.DefaultMarker(_colorHue); markerOptions.SetIcon(bmDescriptor); } _eventLocationMarker = GMap.AddMarker(markerOptions); } else { _eventLocationMarker.Position = _eventLocation; } } if (_userLocation != null) { if (_userLocationMarker == null) { var markerOptions0 = new MarkerOptions(); markerOptions0.SetPosition(_userLocation); markerOptions0.SetIcon(UserLocationIcon); markerOptions0.Anchor(0.5f, 0.5f); _userLocationMarker = GMap.AddMarker(markerOptions0); } else { _userLocationMarker.Position = _userLocation; } } // Set the map type back to normal. GMap.MapType = GoogleMap.MapTypeNormal; }
public TrackPoint(int trackIndex, PointLatLng point, GMap.NET.WindowsForms.GMapRoute relatedRoute) : base(point) { _trackIndex = trackIndex; _route = relatedRoute; }
static void Main(string[] args) { String GMapPath = args[0]; String KMapPath = args[1]; var map = GMap.Load(new FileStream(GMapPath, FileMode.Open)); foreach (var sec in map.Sections) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("-----------------------"); Console.ResetColor(); foreach (var post in sec.Posts) { Console.WriteLine(post); } } var KMap = new XDocument( new XElement(XName.Get("kml", "http://www.opengis.net/kml/2.2"), new XElement("Document", new XElement("name", "Green Field"), map.Sections.Select(sec => GetRandomStyle(sec)), !args.Contains("/l") ? null : map.Sections.Select(sec => new XElement("Placemark", new XElement("name", "line" + GetStyleName(sec)), new XElement("styleUrl", "#" + GetStyleName(sec)), new XElement("LineString", new XElement("coordinates", string.Join(Environment.NewLine, sec.Posts.Select(p => string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0},{1},0", p.Point.Longitude, p.Point.Latitude))))))), !args.Contains("/k") ? null : map.Sections.SelectMany(sec => sec.Posts.Select(p => new XElement("Placemark", new XElement("name", string.Format("{0} км", p.Ordinate / 1000.0)), new XElement("description", string.Format("{0:N0} м", p.Ordinate)), new XElement("styleUrl", "#" + GetStyleName(sec)), new XElement("Point", new XElement("coordinates", string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0},{1},0", p.Point.Longitude, p.Point.Latitude)))))), !args.Contains("/o") ? null : map.Sections.SelectMany(sec => sec.Posts.SelectMany(p => PositeObjects(sec, p).Select(o => new XElement("Placemark", new XElement("name", string.Format("{1}", o.Object.Ordinate / 1000.0, o.Object.ToString())), new XElement("description", string.Format("{1} на {0:F3} км", o.Object.Ordinate / 1000.0, o.Object.ToString())), new XElement("styleUrl", "#" + GetStyleName(sec)), new XElement("Point", new XElement("coordinates", string.Format(CultureInfo.InvariantCulture.NumberFormat, "{0},{1},0", o.Point.Longitude, o.Point.Latitude))))))) ))); KMap.Save(KMapPath); //Console.ReadLine(); }
void Markers_CollectionChanged(object sender, GMap.NET.ObjectModel.NotifyCollectionChangedEventArgs e) { firstload = true; }
public PointLatLngAlt(GMap.NET.PointLatLng pll) { this.Lat = pll.Lat; this.Lng = pll.Lng; }
public ActionResult Map(GMap gmap) { Session["MapData"] = gmap; return(View()); }
public static void UpdateOverlay(GMap.NET.WindowsForms.GMapOverlay poioverlay) { if (poioverlay == null) return; poioverlay.Clear(); foreach (var pnt in POIs) { poioverlay.Markers.Add(new GMarkerGoogle(pnt, GMarkerGoogleType.red_dot) { ToolTipMode = MarkerTooltipMode.OnMouseOver, ToolTipText = pnt.Tag }); } }
public GMapImage(GMap.NET.PointLatLng p) : base(p) { DisableRegionCheck = true; IsHitTestVisible = false; }