using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using Subgurim.Controles;
using System.Web.Security;
using Tuff;
using System.Drawing;
public partial class Action_CarLastLocation : System.Web.UI.Page
{
SysUser sysUser = null;
protected void Page_Init(object sender, EventArgs e)
{
// 用户登录信息
sysUser = (SysUser)Session["SysUser"];
GMap1.Key = WebPublic.GetGoogleMarAPIKey();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));
GMap1.addGMapUI(new GMapUI());
GMap1.GZoom = 4; //缩放等级
GMap1.Width = 590; //控件宽度
GMap1.Height = 600; //控件高度
GMap1.setCenter(new GLatLng(33.00, 106.00));
ObjectDataSourceCarData.SelectParameters["SSGSBH"].DefaultValue = sysUser.Corp.ID;
ObjectDataSourceCarData.SelectParameters["STIME"].DefaultValue = null;
ObjectDataSourceCarData.SelectParameters["ETIME"].DefaultValue = null;
ObjectDataSourceCarData.SelectParameters["SN"].DefaultValue = null;
ASPxGridViewDeviceList.FocusedRowIndex = -1;
}
}
// 加载Map
protected void ASPxGridViewDeviceList_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
{
if (e.RowType == DevExpress.Web.ASPxGridView.GridViewRowType.Data)
{
if (e.VisibleIndex != -1 && e.GetValue("LAT").ToString() != "" && e.GetValue("LON").ToString() != "")
{
double plat = double.Parse(e.GetValue("LAT").ToString()); //得到经度
if (plat == 0.00)
{
plat = 33.00;
}
double plon = double.Parse(e.GetValue("LON").ToString()); //得到纬度
if (plon == 0.00)
{
plon = 106.00;
}
string address = e.GetValue("ADDRESS").ToString();
HiddenFieldMQSSDZ.Value = address;
string registercity = e.GetValue("CLSSQY").ToString(); //得到注册地址
string[] citylist = registercity.Split('/');
string nowcity = citylist[1]; //注册城市
GMarker marker = new GMarker(new GLatLng(plat, plon)); //创建坐标
GLatLng latlon = new GLatLng(plat, plon);
PopupMarkerOptions popupMarkerOptions = new PopupMarkerOptions(Color.White, Color.RoyalBlue); //浮窗样式
PopupMarker popupMarker = new PopupMarker(latlon, "" + e.GetValue("CLCPH") + "", popupMarkerOptions); //定义浮窗
GMap1.Add(popupMarker); //添加到map
GMap1.setCenter(new GLatLng(plat, plon)); //设置中心点
}
}
}
protected void ASPxGridViewDeviceList_FocusedRowChanged(object sender, EventArgs e)
{
if (Page.IsPostBack && ASPxGridViewDeviceList.FocusedRowIndex != -1)
{
GLatLng glatlng = new GLatLng();
string zbwd = ASPxGridViewDeviceList.GetDataRow(ASPxGridViewDeviceList.FocusedRowIndex)["LAT"].ToString();
string zbjd = ASPxGridViewDeviceList.GetDataRow(ASPxGridViewDeviceList.FocusedRowIndex)["LON"].ToString();
if (zbwd != "")
{
if (Math.Abs(double.Parse(zbwd)) < 90)
{
glatlng.lat = double.Parse(zbwd);
}
}
if (zbjd != "")
{
if (Math.Abs(double.Parse(zbjd)) < 180)
{
glatlng.lng = double.Parse(zbjd);
}
}
GMap1.setCenter(glatlng, 14);
}
}
//地图点击事件
protected string GMap1_MarkerClick(object s, GAjaxServerEventArgs e)
{
LabelMQSSDZ.Text = HiddenFieldMQSSDZ.Value;
return e.map;
}
}
asp.Net采用Gmap实现google map定位
最新推荐文章于 2013-02-04 01:15:33 发布
本文介绍了一个基于WebGIS技术实现的车辆实时位置监控系统,详细阐述了系统的核心组件、数据交互流程以及地图展示功能。通过使用ASP.NET MVC框架结合Google Maps API,系统实现了车辆位置的实时获取、地图标记显示以及地图点击事件响应等功能,为车辆管理提供了高效直观的解决方案。
1万+

被折叠的 条评论
为什么被折叠?



