首页 / 浏览问题 / 云GIS / 问题详情
模糊查询之前能实现,地图换坐标系后不能实现了
11EXP 2017年06月07日
下面是一段模糊查询,可以查询到某地并且高亮显示,点击可查询其信息;但是由WGS84换为北京54坐标系后,该功能不能实现了,请帮我查看一下什么原因。

 //地点查询 开始
            var searchMarkerLayer, searchmarker, searchVectorLayer;
            function search() {
                var searchContent = document.getElementById("searchCon").value;
               
                if (searchContent.length <= 0) {
                    alert("请输入查询地点");
                    return;
                }
                searchVectorLayer = new SuperMap.Layer.Vector("searchVectorLayer");
                searchMarkerLayer = new SuperMap.Layer.Markers("searchMarkerlayer");
                map.addLayer(searchMarkerLayer);
                map.addLayer(searchVectorLayer);
                var queryParam, queryBySQLParams, queryBySQLService;
                var layerName = ["XIUXIAN@China400"];

                //FilterParameter 必设 name(查询地图图层名),attributeFilter(SQL条件语句)也为必设   "RoomID like '%" + searchContent + "%'"
                for (var i = 0; i < layerName.length; i++) {
                    queryParam = new SuperMap.REST.FilterParameter({
                        name: layerName[i],
                        attributeFilter: "NAME like '%" + searchContent+"%'",                        fields:"SmID","EAST","NORTH","NAME","LOCATION","INTRODUCE"]
                    });
                    
                    //QueryBySQLParameters 参数必设queryParams
                    queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({ queryParams: [queryParam] });
                    queryBySQLService = new SuperMap.REST.QueryBySQLService(url, { eventListeners: { "processCompleted": searchprocessCompleted, "processFailed": searchprocessFailed} });
                    queryBySQLService.processAsync(queryBySQLParams);
                }
            }
            function searchprocessFailed(e) {
                //alert("404");
                alert(e.error.errorMsg);
            }
            function searchprocessCompleted(queryEventArgs) {
                var result = queryEventArgs.result;
                //显示查找到的矢量要素
                alert(result.totalCount);
                if (result && result.totalCount > 0) {
                    alert("404");
                    for (i = 0; i < result.recordsets.length; i++) {
                        if (result.recordsets[i].features) {
                            for (j = 0; j < result.recordsets[i].features.length; j++) {
                                console.log("**" + result.recordsets[i].features[j].attributes["EAST"]);
                                feature = result.recordsets[i].features[j];
                                feature.style = style;
                                searchVectorLayer.addFeatures(feature);

                                clickSelectInfo = "名称:" + feature.attributes["NAME"] + "<br/>" + "地址:" + feature.attributes["LOCATION"] + "<br/>" + "介绍:" + feature.attributes["INTRODUCE"] + "<br/>";
                                var north = result.recordsets[i].features[j].attributes["NORTH"];
//                                var south = result.recordsets[i].features[j].attributes["SmSdriS"];
//                                var west = result.recordsets[i].features[j].attributes["SmSdriW"];
                                var east = result.recordsets[i].features[j].attributes["EAST"];
                                var x = parseFloat(north);
                                var y = parseFloat(east);
//                                alert(x + "," + y);//4340521,507528
                                console.log("x:"+x);
                                var size = new SuperMap.Size(44, 33);
                                var offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
                                 icon = new SuperMap.Icon('../theme/images/marker.png', size, offset);
                                searchmarker = new SuperMap.Marker(new SuperMap.LonLat(y,x), icon);

                                searchMarkerLayer.addMarker(searchmarker);
                                map.setCenter(new SuperMap.LonLat(y, x), 2);
                                searchmarker.events.on({
                                    "click": clickSelectmouseClickHandler
                                    // "touchstart": mouseClickHandler //假如要在移动端的浏览器也实现点击弹框,则在注册touch类事件
                                });

                            }
                        }
                    }
                } else {
                    // resultTable = "<p>无查询结果!</p>";

                }

            }

1个回答

是查询不出来 跳入失败的事件 还是说跳入成功的事件 地图上没有高亮显示

若是能跳入成功的事件 你在成功的时间里面 直接输出查询的结果 看里面有没有feature
1,620EXP 2017年06月07日
...