首页 / 浏览问题 / 组件GIS / 问题详情
vector图层 弹出一个之定义div
17EXP 2018年10月22日
我想做一个点击vector图层 弹出一个之定义div 我看了 markers 的示例  方法运行但是没有窗口出现

是什么原因,不通用?还是什么,如果示例的话 麻烦发一下。

var map;
var layer;
var marker;
var markers;
var vector;
var wgData;
var url2;
var bt=false;
$(function() {
    GISINFO();
    $(".switch").click(function(){    
        changeMap();
    });
});
function GISINFO() {
    $.post("/gis/tDivisionAction.do?method=GETGISURL", function(data) {
        url2 = data.url2;
        init(data.url1);    
    });

}

// 选项 变量集合
var optionsList = [];
// 初始化地图
function init(url) {
    $("#GisMap").click(function() {
        event.stopPropagation();
    });
    map = new SuperMap.Map("GisMap");
    map.addControl(new SuperMap.Control.LayerSwitcher());

    layer = new SuperMap.Layer.TiledDynamicRESTLayer("顺义区地图", url, {transparent: true, cacheEnabled: true}, {
        maxResolution : "auto"
    });
    markers = new SuperMap.Layer.Markers("标签图层");
    vector = new SuperMap.Layer.Vector("区划网格");

    var callbacks = {
        click : function(currentFeature,event) {
            var name = currentFeature.style.label;
            mouseClickHandler(event);
            //getTongji(name, null);

        }
    };
    var selectFeature = new SuperMap.Control.SelectFeature(vector, {
        callbacks : callbacks
    });
    map.addControl(selectFeature);
    selectFeature.activate();
    layer.events.on({
        "layerInitialized" : addLayer1
    });
    layer.events.on({
        "layerInitialized" : addMarker
    });
    getGrid();
}

// 添加地图图层
function addLayer1()
{
   layerNight = new SuperMap.Layer.TiledDynamicRESTLayer("顺义区地图", url2, {transparent: true, cacheEnabled: true}, {
        maxResolution : "auto"
    });
   layerNight.events.on({"layerInitialized":addLayer2});
 }
// 添加地图
function addLayer2() {
    // map上添加分块动态REST图层和标记图层
    map.addLayers([ layer,layerNight, markers, vector ]);
    map.setCenter(new SuperMap.LonLat(116.61381, 40.17547), 3);

    layer.events.on({"click":mouseClickHandler
        });
}
// 地图弹框
var infowin = null;
function mouseClickHandler(event){
    closeInfoWin();
    //初始化popup类
    popup = new SuperMap.Popup(
            "chicken",
            marker.getLonLat(),
            new SuperMap.Size(175,140),
            "<div>fasdfdsafdsafsdafsdafsdfasdf</div>",
            true,
            null
    );
    //设置弹窗的边框样式
    popup.setBorder("solid 2px #6CA6CD");
    //允许弹出内容的最小尺寸
    popup.mixSize = 200;

    infowin = popup;
    //添加弹窗到map图层
    map.addPopup(popup);
    alert(1);
   
}
function closeInfoWin(){
    if(infowin){
        try{
            infowin.hide();
            infowin.destroy();
        }
        catch(e){}
    }
}

//  地图切换

1个回答

//网格点击事件
    var callbacks = {
        click : function(currentFeature,e) {
            var name = currentFeature.style.label;
            var lonlat=   map.getLonLatFromPixel();
            alert("x="+Math.floor(e.clientX)+","+"y="+Math.floor(e.clientY));
            //getTongji(name, null);

        }
    };
17EXP 2018年10月22日
...