$(function(){ let baseUrl='/C'; // if(window.location.origin=='https://gametest.malls.iformall.com'){ // baseUrl='https://ctest.malls.iformall.com/C' // }else if(window.location.origin=='https://game.malls.iformall.com'){ // baseUrl='https://c.malls.iformall.com/C' // }else if(window.location.origin=='https://game.youlane.cn'){ // baseUrl='https://ciformall.youlane.cn/C' // } init() function init(){ $.ajax({ url:baseUrl + "/api/fengniaomap/getConfig", type:"GET", dataType: "json", //返回数据格式为json headers: { 'content-type':'application/json', "token":"c34103fa-1d40-4ba7-95a4-28975e1d9143:789:wx-cuser", // "token":getQueryString('token') }, success:function(res){ const data = res.data; let mapOptions = { appName: data.appName, key: data.appKey, mapID: data.mapId, container: document.getElementById("fengmap"), mapURL: `/api/mapfile/${data.tenantId}/`, themeURL: `/api/mapfile/${data.tenantId}/theme/`, // mapURL:"../../data/", // themeURL:"../../data/theme/", themeID: data.themeId, } let toolbarOptions = { //控件产生 floorButtonCount: 3, viewModeControl: true, //是否显示2、3D切换按钮,默认为true floorModeControl: true, // 是否显示楼层控件,默认为true needAllLayerBtn: true, //是否显示单多层按钮,默认为true position: 3, //控件位置。分为左上 1、左下2、右上3、右下4。 offset: { x: 0, y: 166 } //控件位置偏移。{x:10,y:10},基于原始位置的x,y方向的偏移。 }; let zoomOptions = { position: 3, //分为左上 1、左下2、右上3、右下4。 offset: { x: 0, y: 50 } //控件位置偏移。{x:10,y:10},基于原始位置的x,y方向的偏移。 }; let compassOptions = { position: 2 //分为左上 1、左下2、右上3、右下4。 }; let map = new fengmap.FMMap(mapOptions); map.on("loaded", function() { let toolbar = new fengmap.FMToolbar(toolbarOptions); //楼层控件 let zoomToolbar = new fengmap.FMZoomControl(zoomOptions); //缩放控件 let compass = new fengmap.FMCompass(compassOptions); //指南针控件 let earch = new fengmap.FMSearchRequest() toolbar.addTo(map); zoomToolbar.addTo(map); compass.addTo(map); compass.on("click", function() { map.setRotation({ rotation: 0, animate: true, duration: 0.3, finish: function() { console.log("setRotation"); } }); }); }); } }) } })