C端蜂鸟地图
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

77 line
3.4 KiB

  1. $(function(){
  2. // let baseUrl='https://ctest.malls.iformall.com/C';
  3. let baseUrl='/C';
  4. // if(window.location.origin=='https://gametest.malls.iformall.com'){
  5. // baseUrl='https://ctest.malls.iformall.com/C'
  6. // }else if(window.location.origin=='https://game.malls.iformall.com'){
  7. // baseUrl='https://c.malls.iformall.com/C'
  8. // }else if(window.location.origin=='https://game.youlane.cn'){
  9. // baseUrl='https://ciformall.youlane.cn/C'
  10. // }
  11. init()
  12. function init(){
  13. $.ajax({
  14. url:baseUrl + "/api/fengniaomap/getConfig",
  15. type:"GET",
  16. dataType: "json", //返回数据格式为json
  17. headers: {
  18. 'content-type':'application/json',
  19. "token":"c34103fa-1d40-4ba7-95a4-28975e1d9143:789:wx-cuser",
  20. // "token":getQueryString('token')
  21. },
  22. success:function(res){
  23. const data = res.data;
  24. let mapOptions = {
  25. appName: data.appName,
  26. key: data.appKey,
  27. mapID: data.mapId,
  28. container: document.getElementById("fengmap"),
  29. mapURL: `/api/mapfile/${data.tenantId}/`,
  30. themeURL: `/api/mapfile/${data.tenantId}/theme/`,
  31. // mapURL:"../../data/",
  32. // themeURL:"../../data/theme/",
  33. themeID: data.themeId,
  34. }
  35. let toolbarOptions = {
  36. //控件产生
  37. floorButtonCount: 3,
  38. viewModeControl: true, //是否显示2、3D切换按钮,默认为true
  39. floorModeControl: true, // 是否显示楼层控件,默认为true
  40. needAllLayerBtn: true, //是否显示单多层按钮,默认为true
  41. position: 3, //控件位置。分为左上 1、左下2、右上3、右下4。
  42. offset: { x: 0, y: 166 } //控件位置偏移。{x:10,y:10},基于原始位置的x,y方向的偏移。
  43. };
  44. let zoomOptions = {
  45. position: 3, //分为左上 1、左下2、右上3、右下4。
  46. offset: { x: 0, y: 50 } //控件位置偏移。{x:10,y:10},基于原始位置的x,y方向的偏移。
  47. };
  48. let compassOptions = {
  49. position: 2 //分为左上 1、左下2、右上3、右下4。
  50. };
  51. let map = new fengmap.FMMap(mapOptions);
  52. map.on("loaded", function() {
  53. let toolbar = new fengmap.FMToolbar(toolbarOptions); //楼层控件
  54. let zoomToolbar = new fengmap.FMZoomControl(zoomOptions); //缩放控件
  55. let compass = new fengmap.FMCompass(compassOptions); //指南针控件
  56. toolbar.addTo(map);
  57. zoomToolbar.addTo(map);
  58. compass.addTo(map);
  59. compass.on("click", function() {
  60. map.setRotation({
  61. rotation: 0,
  62. animate: true,
  63. duration: 0.3,
  64. finish: function() {
  65. // console.log("setRotation");
  66. }
  67. });
  68. });
  69. });
  70. }
  71. })
  72. }
  73. })