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.

index.js 3.4 KiB

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