首页 新闻 会员 周边 捐助

基于GMAP.NET开发 车载实时定位跟踪

0
悬赏园豆:15 [已关闭问题] 关闭于 2013-10-09 10:39

基于GMAP.NET开发 车载实时定位跟踪,我的按关键字查询不了,这是查询代码


//根据城市查询地图
private void BTNSearchAddress_Click_1(object sender, EventArgs e)
{
if (this.TBSAdress.Text.Length == 0)
{
this.TBSAdress.Focus();
MessageBox.Show("请输入查询的地址");
return;
}

this.gMapControl1.ReloadMap();
GMapProvider.Language = LanguageType.ChineseSimplified;
string search = string.Format("{0}", this.TBSAdress.Text);

//判断地址键是否存在。
GeoCoderStatusCode code = gMapControl1.SetCurrentPositionByKeywords(search);
if (code != GeoCoderStatusCode.G_GEO_SUCCESS)
{
MessageBox.Show("地址没有找到:'" + this.TBSAdress.Text + "', 原因:" + code.ToString(), "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}

routes = new GMapOverlay(gMapControl1, "routes");
routes.Markers.Clear();
this.gMapControl1.Overlays.Clear();

AddLocation(TBSAdress.Text);
}

//由地址获得经纬度,再显示地图位置。
private void AddLocation(string place)
{
GeoCoderStatusCode unknow = GeoCoderStatusCode.Unknow;

PointLatLng? latLngFromGeocoder = GMap.NET.MapProviders.GMapProviders.GoogleChinaMap.GetPoint(place, out unknow);
if (latLngFromGeocoder.HasValue && (unknow == GeoCoderStatusCode.G_GEO_SUCCESS))
{
GMapMarker item = new GMapMarkerGoogleGreen(latLngFromGeocoder.Value);
GMapMarkerRect rect = new GMapMarkerRect(latLngFromGeocoder.Value);
rect.Size = new System.Drawing.Size(100, 100);
rect.ToolTipText = place;
rect.ToolTipMode = MarkerTooltipMode.Always;

routes = new GMapOverlay(gMapControl1, "objects");
routes.Markers.Add(item);
routes.Markers.Add(rect);
gMapControl1.Overlays.Add(routes);
//this.label2.Text = this.label1.Text = "";
//this.label1.Text = "经度:" + latLngFromGeocoder.Value.Lng.ToString();
//this.label2.Text = "纬度:" + latLngFromGeocoder.Value.Lat.ToString();
//if (TBSAdress.Text.Length < 4)
//{
// this.gMapControl1.Zoom = 10;
//}
//else
//{
// this.gMapControl1.Zoom += 3;
//}
}
}

麻烦懂的人帮我看下

Danny@yang的主页 Danny@yang | 初学一级 | 园豆:145
提问于:2013-10-08 10:21
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册