silverlight 内嵌百度地图,打开路况,3小时或8小时后自定义标记消失,不能规律重现

silverlight 内嵌百度地图,打开路况,3小时或8小时后自定义标记消失,不能规律重现
消失后返回 silverlight 页面 报错信息为

System.Exception: 错误 0x1709。调试资源字符串不可用。请访问 http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.50901.0&File=mscorrc.dll&Key=0x1709 0x80020101
位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)
位于 MS.Internal.XcpImports.WebBrowser_InvokeScript(DependencyObject obj, String scriptName, String[] parameters)
位于 System.Windows.Controls.WebBrowser.InvokeScript(String scriptName, String[] args)
位于 Sunlight.Silverlight.Dcs.VehicleLogistics.Views.Custom.TrackInTransitForMapDataEditView.SetLocation()
位于 Sunlight.Silverlight.Dcs.VehicleLogistics.Views.Custom.TrackInTransitForMapDataEditView.b__7(LoadOperation1 loadOp)
位于 System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass13
1.b__11(LoadOperation lo)
位于 System.ServiceModel.DomainServices.Client.LoadOperation.<>c__DisplayClass41.<Create>b__0(LoadOperation1 arg)
位于 System.ServiceModel.DomainServices.Client.LoadOperation`1.InvokeCompleteAction()
位于 System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object result)
位于 System.ServiceModel.DomainServices.Client.LoadOperation.Complete(DomainClientResult result)
位于 System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
位于 System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.b__17(Object )

3个回答

public void SetLocation() {

        if(!this.IsLoadCompleted) {
            UIHelper.ShowNotification("由于网络原因,地图尚未加载完全,请重新尝试");
            return;
        }
        //调用加载的百度地图baiduMap.html内的BaiduSearch函数,并且传入值
        if((this.TrackInTransits != null) && this.TrackInTransitCounts != null && IsLoadCompleted) {
            //if(!this.IsLoadCompleted || this.TrackInTransits == null || !this.TrackInTransits.Any()) {
            //    UIHelper.ShowNotification("由于网络原因,地图尚未加载完全,请重新尝试");
            //    return;
            //}
            ////调用加载的百度地图baiduMap.html内的BaiduSearch函数,并且传入值
            //if((this.TrackInTransits != null && this.TrackInTransits.Any()) && this.TrackInTransitCounts != null && this.TrackInTransitCounts.Any() && IsLoadCompleted) {
            var repeatTrackInTransits = this.TrackInTransits.GroupBy(l => new {
                l.TransportVehiclePlate,
                l.VehicleCarrierName,
                l.DriverName,
                l.DriverCellPhoneNumber,
                l.Departure,
                l.LocationTime,
                l.OutTime,
                l.Location
            }).Select(t => t).ToArray();
            var tackInTransitStr = JsonConvert.SerializeObject(repeatTrackInTransits);
            var title = JsonConvert.SerializeObject(this.titles);
            var sumInfo = JsonConvert.SerializeObject(this.SumInfoes);
            var tackInTransitCountStr = JsonConvert.SerializeObject(this.TrackInTransitCounts);
            //try {
               // Dispatcher.BeginInvoke(() => {
                    this.webBrowserMap.InvokeScript("BaiduSearch", tackInTransitStr, title, sumInfo, tackInTransitCountStr);
                //});
            //} 
            //catch {
            //}
            //this.LayoutRoot.Language = XmlLanguage.GetLanguage("zh-CN");
        }
    }

<!DOCTYPE html>







<br> div.BMap_bubble_content<br> {<br> width: auto;<br> height: 100%;<br> overflow-y: auto;<br> overflow-x: hidden;<br> font-family: 微软雅黑;<br> font-size: 13px;<br> min-height: 100%;<br> max-width: 380px;<br> }</p> <pre><code> #divTitle { height: 100%; width: 40px; float: left; min-height: 100%; } #content-Vin { height: 100%; min-height: 100%; float: left; max-width: 286px; word-wrap: break-word; max-height: 200px; } &lt;/style&gt; </code></pre> <p></head><br> <body style="font-size: 12px; height: 100%; overflow: hidden; margin: 0px; padding: 0px;"><br> <form id="form1" name="form1" style="height: 100%;"><br> <div style="width: 100%; height: 100%; min-height: 443px;" id="container"><br> </div><br> <script type="text/javascript"><br> window.onerror = function () { return true; }<br> var map = new BMap.Map(&quot;container&quot;); // ????Map???<br> map.centerAndZoom(new BMap.Point(108.95378, 34.350059), 6); // ????????,????????????????????<br> // map.addControl(new BMap.MapTypeControl()); //地图类型:地图,卫星,三维<br> map.addControl(new BMap.NavigationControl()); //缩放平移控件<br> //map.setCurrentCity(&quot;????&quot;); // ?????????????? ??????????????<br> map.enableScrollWheelZoom(false); //??????????????</p> <pre><code> var ctrl = new BMapLib.TrafficControl({ showPanel: false }); map.addControl(ctrl); ctrl.setAnchor(BMAP_ANCHOR_BOTTOM_RIGHT); function ZoomControl() { this.defaultAnchor = BMAP_ANCHOR_BOTTOM_RIGHT; this.defaultOffset = new BMap.Size(50, 100); } var opts = { minWidth: 300, // 信息窗口宽度 minHeight: 260, // 信息窗口高度 enableMessage: true //设置允许信息窗发送短息 }; function BaiduSearch(trackInTransitsStr, title, sumInfoStr, trackInTransitsCountStr) { var trackInTransits = JSON.parse(trackInTransitsStr); var trackInTransitsCounts = JSON.parse(trackInTransitsCountStr); var titles = JSON.parse(title); var sumInfoes = JSON.parse(sumInfoStr); ZoomControl.prototype = new BMap.Control(); ZoomControl.prototype.initialize = function (map) { var div = document.createElement(&quot;div&quot;); div.appendChild(document.createTextNode(sumInfoes[0] + &quot;:&quot;)); var pWaterway = document.createElement(&quot;p&quot;); pWaterway.style.marginLeft = &quot;20px&quot;; pWaterway.style.lineHeight = &#39;10px&#39;; var pHighway = document.createElement(&quot;p&quot;); pHighway.style.marginLeft = &quot;20px&quot;; pHighway.style.lineHeight = &#39;10px&#39;; var pTrackIn = document.createElement(&quot;p&quot;); pTrackIn.style.lineHeight = &#39;10px&#39;; pTrackIn.innerHTML = sumInfoes[3] + &quot;:&quot;; var highwayCounts = 0; var waterwayCounts = 0; var pUnplanned = document.createElement(&quot;p&quot;); pUnplanned.style.lineHeight = &#39;12px&#39;; var pTobeShipped = document.createElement(&quot;p&quot;); pTobeShipped.style.lineHeight = &#39;12px&#39;; var pHasArrived = document.createElement(&quot;p&quot;); pHasArrived.style.lineHeight = &#39;12px&#39;; var pCompleted = document.createElement(&quot;p&quot;); pCompleted.style.lineHeight = &#39;12px&#39;; highwayCounts = 0; waterwayCounts = 0; for (var i = 0; i &lt; trackInTransitsCounts.length; i++) { var p = document.createElement(&quot;p&quot;); if (trackInTransitsCounts[i].Status.indexOf(&quot;在途&quot;) !== -1) { if (trackInTransitsCounts[i].Status === &quot;在途水路&quot;) waterwayCounts = trackInTransitsCounts[i].Num; if (trackInTransitsCounts[i].Status === &quot;在途公路&quot;) highwayCounts = trackInTransitsCounts[i].Num; pWaterway.innerHTML = sumInfoes[8] + &quot;:&quot; + waterwayCounts + sumInfoes[6]; pHighway.innerHTML = sumInfoes[7] + &quot;:&quot; + highwayCounts + sumInfoes[6]; } else { if (trackInTransitsCounts[i].Status === &quot;未计划&quot;) pUnplanned.innerHTML = sumInfoes[1] + &quot;:&quot; + trackInTransitsCounts[i].Num + sumInfoes[6]; if (trackInTransitsCounts[i].Status === &quot;待发运&quot;) pTobeShipped.innerHTML = sumInfoes[2] + &quot;:&quot; + trackInTransitsCounts[i].Num + sumInfoes[6]; if (trackInTransitsCounts[i].Status === &quot;已到达&quot;) pHasArrived.innerHTML = sumInfoes[4] + &quot;:&quot; + trackInTransitsCounts[i].Num + sumInfoes[6]; if (trackInTransitsCounts[i].Status === &quot;已完成&quot;) pCompleted.innerHTML = sumInfoes[5] + &quot;:&quot; + trackInTransitsCounts[i].Num + sumInfoes[6]; } p.style.lineHeight = &#39;12px&#39;; div.appendChild(p); div.appendChild(pUnplanned); div.appendChild(pTobeShipped); div.appendChild(pTrackIn); div.appendChild(pWaterway); div.appendChild(pHighway); div.appendChild(pHasArrived); div.appendChild(pCompleted); } div.style.cursor = &quot;null&quot;; div.style.border = &quot;1px solid gray&quot;; div.style.backgroundColor = &quot;#5b6b7a&quot;; div.style.color = &quot;white&quot;; div.style.width = &quot;120px&quot;; div.style.minHeight = &quot;150px&quot;; div.style.fontSize = &quot;14px&quot;; div.style.fontWeight = &quot;600&quot;; div.style.padding = &quot;10px&quot;; div.style.fontFamily = &quot;微软雅黑&quot;; div.style.opacity = &quot;0.6&quot;; div.style.marginLeft = &quot;2px&quot;; map.getContainer().appendChild(div); return div; } if (trackInTransits &amp;&amp; trackInTransits.length &gt; 0) { map.clearOverlays(); for (var i = 0; i &lt; trackInTransits.length; i++) { var content = &quot;&lt;div class=&#39;BMap_bubble_content&#39;&gt;&lt;table&gt; &quot;; var point = new BMap.Point(trackInTransits[i][0].Lng, trackInTransits[i][0].Lat); map.centerAndZoom(new BMap.Point(108.95378, 34.350059), 6); var first = trackInTransits[i][0]; content += &#39;&lt;tr&gt;&lt;td&gt;&#39; + titles[0] + &quot;:&quot; + first.TransportVehiclePlate + &#39;&lt;/td&gt;&#39;; content += &#39;&lt;td&gt;&#39; + titles[1] + &quot;:&quot; + first.VehicleCarrierName + &#39;&lt;/td&gt;&lt;/tr&gt;&#39;; content += &#39;&lt;tr&gt;&lt;td&gt;&#39; + titles[2] + &quot;:&quot; + first.DriverName + &#39;&lt;/td&gt;&#39;; content += &#39;&lt;td style=&quot;min-width:160px;width: auto;&quot;&gt;&#39; + titles[3] + &quot;:&quot; + first.DriverCellPhoneNumber + &#39;&lt;/td&gt;&lt;/tr&gt;&#39;; content += &#39;&lt;tr &gt;&lt;td colspan=&quot;2&quot; style=&quot;min-width:200px;width: auto;&quot;&gt;&#39; + titles[4] + &quot;:&quot; + first.LocationTimeStr + &#39;&lt;/td&gt;&lt;/tr&gt;&#39;; content += &#39;&lt;tr&gt;&lt;td style=&quot;min-width:200px;width: auto;&quot;&gt;&#39; + titles[5] + &quot;:&quot; + first.OutTimeStr + &#39;&lt;/td&gt;&#39;; content += &#39;&lt;td&gt;&#39; + titles[6] + &quot;:&quot; + first.Departure + &#39;&lt;/td&gt;&lt;/tr&gt;&#39;; var Destinationtd = &#39;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;margin: 0px 0px 0px 5px;&quot;&gt;&#39; + titles[7] + &quot;:&quot; + first.Destination; var VINtd = &#39;&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;div id=divTitle&gt;&#39; + titles[9] + &quot;:&quot; + &#39;&lt;/div&gt;&#39;; VINtd += &#39;&lt;div id=content-Vin&gt;&#39;; var vinStrs = &#39;&#39;; for (var j = 0; j &lt; trackInTransits[i].length; j++) { if (Destinationtd.indexOf(trackInTransits[i][j].Destination) === -1) Destinationtd += &quot;,&quot; + trackInTransits[i][j].Destination; if (trackInTransits[i].length === j + 1) vinStrs += trackInTransits[i][j].VIN; else { if ((trackInTransits[i][j].VIN.indexOf(&#39;J&#39;) &gt; 0) || trackInTransits[i][j].VIN.indexOf(&#39;I&#39;) &gt; 0) trackInTransits[i][j].VIN = trackInTransits[i][j].VIN + &quot; &quot;; vinStrs += trackInTransits[i][j].VIN + &quot;,&quot;; } } Destinationtd += &#39;&lt;/td&gt;&lt;/tr&gt;&#39;; content += Destinationtd; content += &#39;&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&#39; + titles[8] + &quot;:&quot; + first.Location + &#39;&lt;/td&gt;&lt;/tr&gt;&#39;; VINtd += vinStrs + &#39;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&#39;; content += VINtd; content += &#39;&lt;/table&gt;&#39;; //console.log(content); content += &quot;&lt;/div&gt;&quot;; var myIcon = new BMap.Icon(&quot;http://vvlms.nykautologistics.cn/img/truck_icon_3.gif&quot;, new BMap.Size(100, 33), { offset: new BMap.Size(0, 0), imageOffset: new BMap.Size(0, 0), }); var myLabel = new BMap.Label(first.TransportVehiclePlate, { offset: new BMap.Size(-27, -14), position: point }); myLabel.setStyle({ height: &quot;14px&quot;, width: &quot;60px&quot;, textAlign: &quot;center&quot;, verticalAlign: &quot;bottom&quot; }); map.addOverlay(myLabel); var marker = new BMap.Marker(point, { icon: myIcon }); //console.log(&quot;******************************\r\n&quot; + content); map.addOverlay(marker); addClickHandler(content, marker); //marker.addEventListener(&quot;mouseover&quot;, function (e) { // var p = e.target; // var pointWindow = new BMap.Point(p.getPosition().lng, p.getPosition().lat); // console.log(p.getPosition().lng + &quot;*****&quot; + p.getPosition().lat) // var infoWindow = new BMap.InfoWindow(content, opts); // map.openInfoWindow(infoWindow, pointWindow); //}); } } else { map.clearOverlays(); } var myZoomCtrl = new ZoomControl(); map.addControl(myZoomCtrl); } function addClickHandler(content, marker) { marker.addEventListener(&quot;mouseover&quot;, function (e) { openInfo(content, e); } ); } function openInfo(content, e) { var p = e.target; var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat); var infoWindow = new BMap.InfoWindow(content, opts); // 创建信息窗口对象 map.openInfoWindow(infoWindow, point); //开启信息窗口 } &lt;/script&gt; &lt;/form&gt; </code></pre> <p></body><br> </html></p>
 <!DOCTYPE html>
<html style="height: 100%; overflow: hidden; margin: 0px; padding: 0px;">
<head>
    <title></title>
    <meta charset="utf-8" />
    <link href="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&amp;ak=E32b1688cb718b4dd33a4be1b33bcc53"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script>
    <style>
        div.BMap_bubble_content
        {
            width: auto;
            height: 100%;
            overflow-y: auto;
            overflow-x: hidden;
            font-family: 微软雅黑;
            font-size: 13px;
            min-height: 100%;
            max-width: 380px;
        }

        #divTitle
        {
            height: 100%;
            width: 40px;
            float: left;
            min-height: 100%;
        }

        #content-Vin
        {
            height: 100%;
            min-height: 100%;
            float: left;
            max-width: 286px;
            word-wrap: break-word;
            max-height: 200px;
        }
    </style>
</head>
<body style="font-size: 12px; height: 100%; overflow: hidden; margin: 0px; padding: 0px;">
    <form id="form1" name="form1" style="height: 100%;">
        <div style="width: 100%; height: 100%; min-height: 443px;" id="container">
        </div>
        <script type="text/javascript">
            window.onerror = function () { return true; }
            var map = new BMap.Map("container"); // ????Map???
            map.centerAndZoom(new BMap.Point(108.95378, 34.350059), 6); // ????????,????????????????????
            // map.addControl(new BMap.MapTypeControl());   //地图类型:地图,卫星,三维
            map.addControl(new BMap.NavigationControl()); //缩放平移控件
            //map.setCurrentCity("????");          // ?????????????? ??????????????
            map.enableScrollWheelZoom(false); //??????????????

            var ctrl = new BMapLib.TrafficControl({
                showPanel: false
            });
            map.addControl(ctrl);
            ctrl.setAnchor(BMAP_ANCHOR_BOTTOM_RIGHT);

            function ZoomControl() {
                this.defaultAnchor = BMAP_ANCHOR_BOTTOM_RIGHT;
                this.defaultOffset = new BMap.Size(50, 100);
            }

            var opts = {
                minWidth: 300, // 信息窗口宽度
                minHeight: 260, // 信息窗口高度
                enableMessage: true //设置允许信息窗发送短息
            };

            function BaiduSearch(trackInTransitsStr, title, sumInfoStr, trackInTransitsCountStr) {
                var trackInTransits = JSON.parse(trackInTransitsStr);
                var trackInTransitsCounts = JSON.parse(trackInTransitsCountStr);
                var titles = JSON.parse(title);
                var sumInfoes = JSON.parse(sumInfoStr);
                ZoomControl.prototype = new BMap.Control();
                ZoomControl.prototype.initialize = function (map) {
                    var div = document.createElement("div");
                    div.appendChild(document.createTextNode(sumInfoes[0] + ":"));
                    var pWaterway = document.createElement("p");
                    pWaterway.style.marginLeft = "20px";
                    pWaterway.style.lineHeight = '10px';
                    var pHighway = document.createElement("p");
                    pHighway.style.marginLeft = "20px";
                    pHighway.style.lineHeight = '10px';
                    var pTrackIn = document.createElement("p");
                    pTrackIn.style.lineHeight = '10px';
                    pTrackIn.innerHTML = sumInfoes[3] + ":";
                    var highwayCounts = 0;
                    var waterwayCounts = 0;
                    var pUnplanned = document.createElement("p");
                    pUnplanned.style.lineHeight = '12px';
                    var pTobeShipped = document.createElement("p");
                    pTobeShipped.style.lineHeight = '12px';
                    var pHasArrived = document.createElement("p");
                    pHasArrived.style.lineHeight = '12px';
                    var pCompleted = document.createElement("p");
                    pCompleted.style.lineHeight = '12px';
                    highwayCounts = 0;
                    waterwayCounts = 0;
                    for (var i = 0; i < trackInTransitsCounts.length; i++) {
                        var p = document.createElement("p");
                        if (trackInTransitsCounts[i].Status.indexOf("在途") !== -1) {
                            if (trackInTransitsCounts[i].Status === "在途水路")
                                waterwayCounts = trackInTransitsCounts[i].Num;
                            if (trackInTransitsCounts[i].Status === "在途公路")
                                highwayCounts = trackInTransitsCounts[i].Num;
                            pWaterway.innerHTML = sumInfoes[8] + ":" + waterwayCounts + sumInfoes[6];
                            pHighway.innerHTML = sumInfoes[7] + ":" + highwayCounts + sumInfoes[6];
                        } else {
                            if (trackInTransitsCounts[i].Status === "未计划")
                                pUnplanned.innerHTML = sumInfoes[1] + ":" + trackInTransitsCounts[i].Num + sumInfoes[6];
                            if (trackInTransitsCounts[i].Status === "待发运")
                                pTobeShipped.innerHTML = sumInfoes[2] + ":" + trackInTransitsCounts[i].Num + sumInfoes[6];
                            if (trackInTransitsCounts[i].Status === "已到达")
                                pHasArrived.innerHTML = sumInfoes[4] + ":" + trackInTransitsCounts[i].Num + sumInfoes[6];
                            if (trackInTransitsCounts[i].Status === "已完成")
                                pCompleted.innerHTML = sumInfoes[5] + ":" + trackInTransitsCounts[i].Num + sumInfoes[6];
                        }
                        p.style.lineHeight = '12px';
                        div.appendChild(p);
                        div.appendChild(pUnplanned);
                        div.appendChild(pTobeShipped);
                        div.appendChild(pTrackIn);
                        div.appendChild(pWaterway);
                        div.appendChild(pHighway);
                        div.appendChild(pHasArrived);
                        div.appendChild(pCompleted);
                    }
                    div.style.cursor = "null";
                    div.style.border = "1px solid gray";
                    div.style.backgroundColor = "#5b6b7a";
                    div.style.color = "white";
                    div.style.width = "120px";
                    div.style.minHeight = "150px";
                    div.style.fontSize = "14px";
                    div.style.fontWeight = "600";
                    div.style.padding = "10px";
                    div.style.fontFamily = "微软雅黑";
                    div.style.opacity = "0.6";
                    div.style.marginLeft = "2px";
                    map.getContainer().appendChild(div);
                    return div;
                }

                if (trackInTransits && trackInTransits.length > 0) {
                    map.clearOverlays();
                    for (var i = 0; i < trackInTransits.length; i++) {
                        var content = "<div class='BMap_bubble_content'><table> ";
                        var point = new BMap.Point(trackInTransits[i][0].Lng, trackInTransits[i][0].Lat);
                        map.centerAndZoom(new BMap.Point(108.95378, 34.350059), 6);
                        var first = trackInTransits[i][0];
                        content += '<tr><td>' + titles[0] + ":" + first.TransportVehiclePlate + '</td>';
                        content += '<td>' + titles[1] + ":" + first.VehicleCarrierName + '</td></tr>';
                        content += '<tr><td>' + titles[2] + ":" + first.DriverName + '</td>';
                        content += '<td  style="min-width:160px;width: auto;">' +
                            titles[3] +
                            ":" +
                            first.DriverCellPhoneNumber +
                            '</td></tr>';
                        content += '<tr ><td colspan="2" style="min-width:200px;width: auto;">' +
                            titles[4] +
                            ":" +
                            first.LocationTimeStr +
                            '</td></tr>';
                        content += '<tr><td style="min-width:200px;width: auto;">' +
                            titles[5] +
                            ":" +
                            first.OutTimeStr +
                            '</td>';
                        content += '<td>' + titles[6] + ":" + first.Departure + '</td></tr>';
                        var Destinationtd = '<tr><td  colspan="2" style="margin: 0px 0px 0px 5px;">' +
                            titles[7] +
                            ":" +
                            first.Destination;
                        var VINtd = '<tr><td  colspan="2"> <div id=divTitle>' + titles[9] + ":" + '</div>';
                        VINtd += '<div id=content-Vin>';
                        var vinStrs = '';
                        for (var j = 0; j < trackInTransits[i].length; j++) {
                            if (Destinationtd.indexOf(trackInTransits[i][j].Destination) === -1)
                                Destinationtd += "," + trackInTransits[i][j].Destination;
                            if (trackInTransits[i].length === j + 1)
                                vinStrs += trackInTransits[i][j].VIN;
                            else {
                                if ((trackInTransits[i][j].VIN.indexOf('J') > 0) || trackInTransits[i][j].VIN.indexOf('I') > 0)
                                    trackInTransits[i][j].VIN = trackInTransits[i][j].VIN + " ";
                                vinStrs += trackInTransits[i][j].VIN + ",";
                            }
                        }
                        Destinationtd += '</td></tr>';
                        content += Destinationtd;
                        content += '<tr><td colspan="2">' + titles[8] + ":" + first.Location + '</td></tr>';
                        VINtd += vinStrs + '</div></td></tr>';
                        content += VINtd;
                        content += '</table>';
                        //console.log(content);
                        content += "</div>";
                        var myIcon = new BMap.Icon("http://vvlms.nykautologistics.cn/img/truck_icon_3.gif",
                            new BMap.Size(100, 33),
                            {
                                offset: new BMap.Size(0, 0),
                                imageOffset: new BMap.Size(0, 0),
                            });

                        var myLabel = new BMap.Label(first.TransportVehiclePlate,
                        {
                            offset: new BMap.Size(-27, -14),
                            position: point
                        });
                        myLabel.setStyle({
                            height: "14px",
                            width: "60px",
                            textAlign: "center",
                            verticalAlign: "bottom"
                        });
                        map.addOverlay(myLabel);

                        var marker = new BMap.Marker(point, { icon: myIcon });
                        //console.log("******************************\r\n" + content);
                        map.addOverlay(marker);
                        addClickHandler(content, marker);
                        //marker.addEventListener("mouseover", function (e) {
                        //    var p = e.target;
                        //    var pointWindow = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
                        //    console.log(p.getPosition().lng + "*****" + p.getPosition().lat)
                        //    var infoWindow = new BMap.InfoWindow(content, opts);
                        //    map.openInfoWindow(infoWindow, pointWindow);
                        //});
                    }
                } else {
                    map.clearOverlays();
                }
                var myZoomCtrl = new ZoomControl();
                map.addControl(myZoomCtrl);
            }

            function addClickHandler(content, marker) {
                marker.addEventListener("mouseover",
                    function (e) {
                        openInfo(content, e);
                    }
                );
            }

            function openInfo(content, e) {
                var p = e.target;
                var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
                var infoWindow = new BMap.InfoWindow(content, opts); // 创建信息窗口对象
                map.openInfoWindow(infoWindow, point); //开启信息窗口
            }

        </script>
    </form>
</body>
</html>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐