projectMap.js 2.17 KB

let action = null;
var app = null;
layui.config({
    base: "/js/",
    version: 1
}).use(['system'], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        sendDataWhere = null,
        areaName = "configure",
        controllerName = "BaseProject",
        mapObj = null;

    action = {

    }

    app = {
        data: {
            mapEle:"container"
        },
        methods: {
            initMap() {
                mapObj = mapApp(app.data.mapEle).initMap();
            },

            getProjectData() {
                var ajaxConfig = {
                    data: null,
                    url: `/configure/BaseProject/Load`,
                    success: function (result) {
                        if (sysU.successBefore(result)) return false;
                        app.methods.createMarkerInfo(result.Result)
                    }
                };
                sysU.ajax(ajaxConfig);
            },
            createMarkerInfo(json) {
                json.forEach(item => {
                    var content = `<h4 style = 'margin:0;'>${item.projectAddress}</h4><br/>
                            这里是显示项目信息
                            <div style = 'display: flex;' >
                              <div><a style='text-decoration: underline;color: blue;' onclick='app.methods.mapMarkerClick(${JSON.stringify(item)})'  href='#'>点击链接</a></div>
                            </div >` ;//定义大标题  html语句标签
                    mapObj.createMarkerInfo(content, {
                        title: item.projectName,
                        longitude: item.longitude,
                        latitude: item.latitude
                    });
                })
            },
            mapMarkerClick(item) {
                alert(JSON.stringify(item))
            }
        },
        registerEvent: function () {

        },
        init: function () {
            debugger
            app.methods.initMap();
            app.methods.getProjectData();
            app.registerEvent();
        }
    };
    app.init();
});