在vue中使用超圖標(biāo)繪服務(wù)

1、使用vue-cli新建一個(gè)vue工程。
2、下載supermap iclient for leaflet 10.01的下載包璃吧,將supermap iclient for leaflet 10.01的下載包中的dist文件夾和examples中的js、img废境、locales文件夾拷貝到vue工程中public文件夾目錄中畜挨。
3、下載leaflet彬坏,將leaflet拷貝到vue工程中public文件夾目錄中朦促。


1.png

4、在index.html中添加標(biāo)簽引入leaflet栓始、supermap以及超圖標(biāo)繪相關(guān)文件务冕。

  <link rel="stylesheet" href="./leaflet/dist/leaflet.css" />
  <script src="./leaflet/dist/leaflet.js"></script>
  <link rel="stylesheet"  />
  <script type="text/javascript" src="https://iclient.supermap.io/dist/leaflet/iclient-leaflet.js"></script>

  <script type="text/javascript" include="bootstrap,plottingPanel" src="./js/include-web.js"></script>
  <script type="text/javascript" include="iclient-plot-leaflet" src="./dist/leaflet/include-leaflet.js"></script>
  <script type="text/javascript" include="PlotPanel" src="./js/plottingPanel/PlottingPanel.Include.js"></script>

5、在組件中即可使用(超圖示例幻赚,清空禀忆、取消功能不可用,代碼需進(jìn)行修改)落恼。

<template>
  <div
    style="margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;"
  >
    <div
      id="toolbar"
      class="panel panel-primary"
      style="position: absolute;top: 15px;right: 60px;text-align: center;z-index: 9999;border-radius: 4px;"
    >
      <div class="panel-heading" id="panelheading">
        <h5
          class="panel-title text-center"
          style=" color: #ffffff;font-size: 16px;"
        >鼠標(biāo)標(biāo)繪</h5>
      </div>
      <div class="panel-body content" id="panelbodycontent">
        <div align="right" class="button-group">
          <input
            type="button"
            class="btn btn-default"
            value="取消標(biāo)繪"
            onclick="PlottingDrawCancel()"
          />&nbsp;&nbsp;
          <input
            type="button"
            class="btn btn-default"
            value="清空標(biāo)繪"
            onclick="clearLayers()"
          />
        </div>
      </div>
    </div>
    <div id="plottingPanel">
      <div
        class="easyui-panel"
        style="position:absolute;top:0px;bottom:0px;left:0px;right:0px;padding:5px; width: 100%;"
      >
        <div class="easyui-tabs" style="width: 100%;height: 100%">
          <div id="plotPanel" style="overflow: hidden">標(biāo)繪面板</div>
        </div>
      </div>
    </div>
    <div id="map"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
    var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
    var map;
    map = L.map("map", {
      preferCanvas: true,
      crs: L.CRS.EPSG4326,
      center: [35, 104],
      maxZoom: 18,
      zoom: 3
    });
    L.supermap.tiledMapLayer(url).addTo(map);
    var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
    plottingLayer.spatialAnalystUrl =
      host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
    plottingLayer.addTo(map);
    var drawControl = L.supermap.plotting.drawControl(plottingLayer);
    drawControl.addTo(map);
    var editControl = L.supermap.plotting.editControl();
    editControl.addTo(map);
    L.supermap.plotting.initPlotPanel("plotPanel", serverUrl, drawControl);

    function clearLayers() {
      plottingLayer.removeAllFeatures();
    }

    function PlottingDrawCancel() {
      drawControl.handler.disable();
    }
  },
  methods: {},
  components: {}
};
</script>
<style  scoped>
#map {
  position: absolute;
  left: 250px;
  right: 0px;
  height: 100%;
}

#plottingPanel {
  float: left;
  background: #ffffff;
  width: 250px;
  height: 100%;
  border: 1px solid #3473b7;
}
</style>

6箩退、啟動(dòng)npm run dev,結(jié)果如下:


2.jpg
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市佳谦,隨后出現(xiàn)的幾起案子戴涝,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,386評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件啥刻,死亡現(xiàn)場離奇詭異奸鸯,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)可帽,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,142評論 3 394
  • 文/潘曉璐 我一進(jìn)店門娄涩,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人映跟,你說我怎么就攤上這事蓄拣。” “怎么了努隙?”我有些...
    開封第一講書人閱讀 164,704評論 0 353
  • 文/不壞的土叔 我叫張陵球恤,是天一觀的道長。 經(jīng)常有香客問我荸镊,道長碎捺,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,702評論 1 294
  • 正文 為了忘掉前任贷洲,我火速辦了婚禮,結(jié)果婚禮上晋柱,老公的妹妹穿的比我還像新娘优构。我一直安慰自己,他們只是感情好雁竞,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,716評論 6 392
  • 文/花漫 我一把揭開白布钦椭。 她就那樣靜靜地躺著,像睡著了一般碑诉。 火紅的嫁衣襯著肌膚如雪彪腔。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,573評論 1 305
  • 那天进栽,我揣著相機(jī)與錄音德挣,去河邊找鬼。 笑死快毛,一個(gè)胖子當(dāng)著我的面吹牛格嗅,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播唠帝,決...
    沈念sama閱讀 40,314評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼屯掖,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了襟衰?” 一聲冷哼從身側(cè)響起贴铜,我...
    開封第一講書人閱讀 39,230評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后绍坝,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體徘意,經(jīng)...
    沈念sama閱讀 45,680評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,873評論 3 336
  • 正文 我和宋清朗相戀三年陷嘴,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了映砖。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,991評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡灾挨,死狀恐怖邑退,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情劳澄,我是刑警寧澤地技,帶...
    沈念sama閱讀 35,706評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站秒拔,受9級特大地震影響莫矗,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜砂缩,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,329評論 3 330
  • 文/蒙蒙 一作谚、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧庵芭,春花似錦妹懒、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,910評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至好乐,卻和暖如春匾竿,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背蔚万。 一陣腳步聲響...
    開封第一講書人閱讀 33,038評論 1 270
  • 我被黑心中介騙來泰國打工岭妖, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人反璃。 一個(gè)月前我還...
    沈念sama閱讀 48,158評論 3 370
  • 正文 我出身青樓区转,卻偏偏與公主長得像,于是被迫代替她去往敵國和親版扩。 傳聞我的和親對象是個(gè)殘疾皇子废离,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,941評論 2 355