备份:DpMap一期修改
sendRequest.js
- //
- /ShopProductSales.aspx modify by elifefly 2008.8.21
- //
- function ReqShopProductSales()
- {
- var s = "storename=" + $("storename").value //门店名称
- + "&retailername=" + $("retailername").value //隶属连锁商
- + "&starttime=" + $("sBegin_sBegin").value //上报时间 起 //sBegin_sBegin对应页面中cBegin这个标签
- + "&endtime=" + $("sEnd_sEnd").value //上报日期 止 //sEnd_sEnd对应页面中sEnd这个标签
- + "&corpid=" + $("CorpId").value; //企业ID,CorpId /CorpId add by elifefly 2008.9.7
- var url = "./shopProductSales.ashx?" + s;
- url = encodeURI(url);///对url中文参数处理/// add by elifefly 2008.8.22/
- xhrSendRequest.open("post",url,false);
- xhrSendRequest.setRequestHeader("Content-Length",url.length);
- xhrSendRequest.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
- xhrSendRequest.onreadystatechange = showShopProductSalesGeoPoints; //调用showShopProductSalesGeoPoints()
- xhrSendRequest.send();
- }
- function showShopProductSalesGeoPoints() //在地图上显示从服务端返回的地理数据
- {
- if (xhrSendRequest.readyState==4 || xhrSendRequest.readyState=="complete")
- {
- var points = [];
- var items = null;
- try
- {
- items = eval("(" + xhrSendRequest.responseText + ")");
- }
- catch(ex)
- {
- alert("没有你要找的门店!");
- }
- var marker = null;//标注点符号
- var point = null;//地理点
- var storename = null;//标注点名称
- var salescount = null;//产品销量
- var avgprice = null;
- var sumprice = null;
- if(!items) return;
- map.clearOverLays();
- for (i=0; i<(items.length); i++)
- {
- var node = items[i];
- if(!node) continue;
- point = new LTPoint(parseInt(node.Longitude),parseInt(node.Latitude));//根据读取的经度和纬度创建一个地理点坐标--标注点
- points.push(point); //入栈,把标注点装入points = []数组,因为标注点有多个
- 获取节点 add by elifefly 2008.8.21///
- storename = node.storeName; //获取节点
- salescount = node.sumDistrib;
- avgprice = node.avgPrice;
- sumprice = node.sumPrice;
- 获取节点 add by elifefly 2008.8.21///
- //设置点的样式,高,宽
- var ptIcon = new LTIcon();
- ptIcon.setWidth( 32 );
- ptIcon.setHeight( 32 );
- marker = new LTMarker(point,ptIcon); //标注点根据标注点图标的大小选择性的显示出来,避免标注点过于密集
- ptIcon.setImageUrl( "./icons/s/red.gif" ); /设置默认门店标注点图标/// add by elifefly 2008.8.21/
- var text = new LTMapText( marker ); //创建一个文本标注对象,该对象显示在指定的地理位置或标注处
- if($("checkNumInfo").checked == true)
- {
- text.setLabel( "<div style=background:#809FFF;><span style=font-size:14px; font-color:#FFFFFF;><strong>" + storename + "</strong></span><br/><span style=font-size:12px; font-color:#FFFFFF;>产品销量:" + salescount +" 平均单价:"+ avgprice +" 零售总额:"+ sumprice +"</span><br/></div>");
- map.addOverLay( text ); //指定的座标出显示文本,对地图进行拖放等操作,文本将始终保持在该坐标处
- }
- map.addOverLay(marker); //在标记的图标上显示一个信息浮窗,该信息浮窗箭头指向该标记;
- }
- var c = new LTSmallMapControl(); //显示地图最小工具栏
- map.addControl(c);
- map.setCenterAtLatLng(point); //将地图的中心点直接变换到指定的地理坐标,不执行滑动过程
- //map.zoomTo(9); //将视图切换到指定的缩放等级9,中心点坐标不变
- map.getBestMap(points); //地图会自动的选择最佳视图(缩放等级和中心点坐标),以显示数组之中的所有点
- //
- }
- }
shopProductSales.js
- shopProductSales.js add by elifefly 2008.8.22
- /shopProductSales.js 用于ShopProductSales.aspx页面地图初始化所有门店标注点
- var map;//地图对象
- var editMark;//当前正在编辑的标注
- var defaultCenter = new LTPoint(10671030,3310736);//默认的地图中心
- var defalutMapLevel = 13; //默认的地图级别
- var markCollection;
- var markOper;
- var currentTool;
- var defaultTool;
- var markerTool;
- var iconsWin;
- //地图初始化
- function onLoad()
- {
- map = new LTMaps("mapDiv"); //mapDiv是页面标签/LTMaps("mapDiv")函数使用指定的mapDiv层创建一个地图对象
- map.centerAndZoom(defaultCenter,defalutMapLevel); /创建默认地图,使用默认的中心位置的经纬度和“缩放级别”
- map.addControl(new LTStandMapControl()); 为地图添加标准导航控件
- 生成标记管理类 LTMarkerCollection(map) add by elifefly 2008.8.16
- //markCollection =new LTMarkerCollection(map);/
- //markOper = new MarkerOper(map);/
- map.handleKeyboard();//启用键盘
- map.handleMouseScroll();//启用鼠标滚轮功能支持,参数true代表使用鼠标指向点位置不变模式
- initTools(); //初始化工具栏
- initMarkerOper();
- ///initIcons()函数有问题,待改进
- ///initIcons();///绑定各种彩色标注图标//
- initMapDivSize(); 加载地图的层大小值
- // RequestAllStoreMark() add by elifefly 2008.8.22//
- //加载所有已经标注的门店标注点/
- // RequestAllStoreMark();
- }
- //地图的层大小
- function initMapDivSize()
- {
- document.getElementById("mapDiv").style.height = window.screen.availHeight * 0.75;
- }
- //获取下拉框中的选择值
- function getSelectedValue(id)
- {
- var selectControl = $(id);
- return selectControl.options(selectControl.selectedIndex).innerHTML;
- }
- //根据id获取要素
- function $(id)
- {
- return document.getElementById(id);
- }
- function CreateXMLDom()
- {
- if(window.ActiveXObject)
- {
- var arrSignatures = ["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0",
- "MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XMLDom"];
- for (var i = 0; i < arrSignatures.length;i++)
- {
- try
- {
- var oXmlDom = new ActiveXObject(arrSignatures[i]);
- return oXmlDom;
- }
- catch(oError){}
- }
- throw new Error("MSXML is not installed on your system");
- }
- else if(document.implementation && document.implementation.cereateDocument)
- {
- var oXmlDom = document.implementation.createDocument("","",null);
- return oXmlDom;
- }
- else
- {
- throw new Error("Your browser doesn't support an XML DOM object");
- }
- }
- function RequestAllStoreMark() //显示所有标注点
- {
- //var s 无条件查询/// add by elifefly 2008.8.22/
- var s = "storename=" //门店名称
- + "&retailername=" //隶属连锁商
- + "&starttime=" //上报时间 起 //sBegin_sBegin对应页面中cBegin这个标签
- + "&endtime=" //上报日期 止 //sEnd_sEnd对应页面中sEnd这个标签
- var url = "./shopProductSales.ashx?" + s;
- url = encodeURI(url);///对url中文参数处理/// add by elifefly 2008.8.22/
- xhrSendRequest.open("post",url,false);
- xhrSendRequest.setRequestHeader("Content-Length",url.length);
- xhrSendRequest.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
- xhrSendRequest.onreadystatechange = showShopProductSalesGeoPoints; //调用showShopProductSalesGeoPoints()
- xhrSendRequest.send();
- }
shopProductSales.ashx
- <%@ WebHandler Language="C#" Class="shopProductSales" %>
- using System;
- using System.Web;
- using System.Data;
- /// <summary>
- /// 右侧查询条件
- /// </summary>
- //
- /ShopProductSales.aspx门店-产品销售的查询
- //
- public class shopProductSales : IHttpHandler {
- public void ProcessRequest (HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- string storeName = context.Request.QueryString["storename"]; //门店名称
- string retailerName = context.Request.QueryString["retailername"]; //隶属连锁商
- string startTime = context.Request.QueryString["starttime"]; //上报时间 起
- string endTime = context.Request.QueryString["endtime"]; //上报日期 止
- string corpId = context.Request.QueryString["corpid"]; //企业ID,CorpId /CorpId add by elifefly 2008.9.7
- string result = this.GetshopProductSales(storeName, retailerName, startTime, endTime, corpId); //调用GetshopProductSales
- context.Response.Clear(); //清空服务器端为此会话开辟的输出缓存
- context.Response.Write(result);//将结果写入到服务器端为此会话开辟的输出缓存中
- context.Response.Flush();
- context.Response.Close();//将服务器端为此会话开辟的输出缓存中的信息传送到客户端
- }
- private string GetshopProductSales(string storeName, string retailerName, string startTime, string endTime, string corpId)
- {
- start判断参数是否为空,如果为空,则相应的条件置空///add by elifefly 2008.8.21/
- string storenamesql = " ";
- string retailernamesql = " ";
- string starttimesql = " ";
- string endtimesql = " ";
- //storenamesql 门店名称
- if (storeName !=string.Empty)
- {
- storenamesql = " StoreName like '%" + storeName + "%' and";
- }
- // retailernamesql 隶属连锁商
- if (retailerName !=string.Empty)
- {
- retailernamesql = " RetailerName like '%" + retailerName + "%' and";
- }
- //starttimesql 上报时间 起
- if (startTime != string.Empty)
- {
- starttimesql = " convert(varchar(10),RecvTime,120) >='" + startTime + "' and";
- }
- //endtimesql 上报日期 止
- if (endTime !=string.Empty)
- {
- endtimesql = " convert(varchar(10),recvtime,120)<'" + endTime + "' and";
- }
- end判断参数是否为空,如果为空,则相应的条件置空///add by elifefly 2008.8.21/
- string sql = "select distinct StoreName, Longitude ,Latitude, sum(Distribution) as sumDistrib, convert(numeric(15,2),isnull(sum(Price*Distribution)/sum(Distribution),0)) as avgPrice,isnull(sum(Price*Distribution),0) as sumPrice"
- + " from V_Map where"
- + starttimesql // + " convert(varchar(10),RecvTime,120)>='2008-08-18'"
- + endtimesql //+ " and convert(varchar(10),recvtime,120) < '2008-08-19'"
- + storenamesql // + " and StoreName like '%广州%'"
- + retailernamesql //+ " and RetailerName like '%gome%'"
- + " Longitude is not null and Latitude is not null"
- + " and CorpId ='" + corpId + "' " //企业Id add by elifefly 2008.9.7//
- + " group by StoreName,Longitude,Latitude ";
- System.Data.DataTable dtResult = Utils.Instance.GetDataFromSqlServerr(sql);
- string result = "[";
- foreach(System.Data.DataRow dr in dtResult.Rows)
- {
- result += "{";
- result += string.Format("storeName:'{0}',Longitude:'{1}',Latitude:'{2}',sumDistrib:'{3}',avgPrice:'{4}',sumPrice:'{5}'", dr["StoreName"].ToString(), dr["Longitude"].ToString(), dr["Latitude"].ToString(), dr["sumDistrib"].ToString(), dr["avgPrice"].ToString(), dr["sumPrice"].ToString());
- result += "},";
- }
- if (result.Length > 1)
- {
- result = result.Remove(result.Length - 1);
- }
- result += "]";
- /start//如果result返回结果为空,则不返回任何值///add by elifefly 2008.8.22/
- if (result == "[]")
- {
- return "";
- }
- else
- {
- return result;
- }
- end///如果result返回结果为空,则不返回任何值///add by elifefly 2008.8.22/
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
ShopProductSales.aspx
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShopProductSales.aspx.cs" Inherits="Webroot_DPCS_51ditu_ProductSales" %>
- <%@ Register TagPrefix="cc1" Namespace="Myvas.Web.UI.WebControls" Assembly="Myvas.Web.UI.WebControls" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head id="Head1" runat="server">
- <title>门 店 - 产品销售</title>
- <link rel="stylesheet" type="text/css" href="StyleSheet.css" />
- <script language="javascript" src="http://api.51ditu.com/js/maps.js" type="text/jscript"></script>
- <script language="javascript" src="http://api.51ditu.com/js/ajax.js" type="text/jscript"></script>
- <script language="javascript" src="./js/tools.js" type="text/jscript"></script>
- <script language="javascript" src="./js/shopProductSales.js" type="text/jscript"></script>
- <script language="javascript" src="./js/postdata.js" type="text/jscript"></script>
- <script language="javascript" src="./js/marker.js" type="text/jscript"></script>
- <script language="javascript" src="./js/getdata.js" type="text/jscript"></script>
- <script language="javascript" src="./js/business.js" type="text/jscript"></script>
- <script language="javascript" src="./js/sendRequest.js" type="text/jscript"></script>
- </head>
- <body οnlοad="onLoad()">
- <form id="form1" runat="server">
- <div>
- <div class="headInfo" style="left: 0px; top: 0px"><div class="MapName">门 店 - 产品销售</div><div class="helpTitle" style="width:auto;"><a href="#">帮 助</a></div></div>
- <div id="toolsDiv" class="Tools" ></div>
- <div id="bzDiv" class="selSection">
- <div class="rightSelectionHead" ><div class="SelectionTitle">查询条件</div></div>
- <div class="bzContont" style="left: 2px; top: 0px; width:194px; height:520px;"> <br />
- <span style="margin-left:10px; font-family:黑体; font-size:14px; color:#7B8DBD; margin-top:10px;">门店选择</span>
- <table style="margin-top:5px; margin-left:20px;"><tr><td>
- <span style="font-size:14px;">门店名称 </span><input id="storename" name="storename" size="12" style="margin-left:11px;" /></td></tr>
- <tr><td style="height: 42px"><span style="font-size:14px;">隶属连锁商 </span><input id="retailername" name="retailername" size="12" style="margin-left:11px;" /></td>
- </tr>
- </table>
- <br/>
- <span style="margin-left:10px; font-family:黑体; font-size:14px; color:#7B8DBD; margin-top:10px;">数据时间范围<br />
- </span> <table style="margin-top: 30px; margin-left: 20px">
- <tr>
- <td style="width: 116px">
- <div class="dateTitle">
- 上报时间 起</div>
- </td>
- </tr>
- <tr>
- <td style="width: 116px; height: 12px">
- <cc1:DateTimeSelector ID="sBegin" runat="server" DateStyle="yyyy-MM-dd" SitePath="../../DateTimeSelector/"
- Width="127px" />
- <div class="dateTitle">上报日期 止</div><cc1:DateTimeSelector ID="sEnd" runat="server" DateStyle="yyyy-MM-dd" SitePath="../../DateTimeSelector/"
- Width="129px" />
- </td>
- </tr>
- </table>
- <br />
- <div class="inputTitle"><input type="checkbox" id="checkNumInfo" name="checkNumInfo" tabindex="0" value="on" οnclick="ReqShopProductSales()" /> 出现数据框</div>
- <div id="btnQuery" style="margin-top:30px; margin-left:70px;">
- <input id="btnViewPOI" type="button" value="查 询" οnclick="ReqShopProductSales()" /></div>
- </div><asp:HiddenField ID="CorpId" runat="server" /><!-- CorpId add by elifefly 2008.9.7 -->
- </div>
- <div id="mapDiv" class="map"></div>
- </div>
- </form>
- </body>
- </html>
ShopProductSales.aspx.cs
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class Webroot_DPCS_51ditu_ProductSales : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack) //为上报时间 起---添加默认日期(昨天日期)
- {
- this.sBegin.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
- this.sEnd.Text = DateTime.Now.ToString("yyy-MM-dd");
- this.CorpId.Value = Session["CorpId"].ToString(); /CorpId add by elifefly 2008.9.7
- }
- }
- }