1+ <!--********************************************************************
2+ * Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
3+ *********************************************************************-->
4+ <!DOCTYPE html>
5+ < html >
6+ < head >
7+ < meta charset ="UTF-8 ">
8+ < title data-i18n ="resources.title_webMap_Vue "> </ title >
9+ < script type ="text/javascript " include ="vue " src ="../js/include-web.js "> </ script >
10+ < script type ="text/javascript " include ='mapbox-gl-enhance ' src ="../../dist/mapboxgl/include-mapboxgl.js "> </ script >
11+ </ head >
12+ < body style =" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0; ">
13+ < div id ='app ' style ="margin:0 auto;width: 100%;height: 100% ">
14+ < div id ="map " style ="margin:0 auto;width: 100%;height: 100% "> </ div >
15+ < webmap server-id ='1649097980 ' :web-map-options ="webMapOptions " @add-layers-succeed ="addLayersSucceeded "> </ webmap >
16+ </ div >
17+ < script >
18+
19+ var webMapComponent = {
20+ props : {
21+ serverId : {
22+ type : String ,
23+ required : true
24+ } ,
25+ webMapOptions : {
26+ type : Object
27+ }
28+ } ,
29+ template : `<div v-if="!webMapOptions.target" id="map"></div>` ,
30+ mounted ( ) {
31+ var webmap = this . initializeWebMap ( ) ;
32+ this . webmap = webmap ;
33+ this . registerEvents ( webmap ) ;
34+ } ,
35+ methods : {
36+ initializeWebMap ( ) {
37+ var webmap = new mapboxgl . supermap . WebMap ( this . serverId , this . webMapOptions ) ;
38+ return webmap ;
39+ } ,
40+ registerEvents ( webmap ) {
41+ var _this = this ;
42+ webmap . on ( "getmapfailed" , function ( e ) {
43+ _this . $emit ( "get-map-failed" , e ) ;
44+ } ) ;
45+ webmap . on ( "getwmtsfailed" , function ( e ) {
46+ _this . $emit ( "get-wmts-failed" , e ) ;
47+ } ) ;
48+ webmap . on ( "getlayersfailed" , function ( e ) {
49+ _this . $emit ( "get-layers-failed" , e ) ;
50+ } ) ;
51+ webmap . on ( "getfeaturesfailed" , function ( e ) {
52+ _this . $emit ( "get-features-failed" , e ) ;
53+ } ) ;
54+ webmap . on ( "addlayerssucceeded" , function ( e ) {
55+ _this . $emit ( "add-layers-succeed" , e ) ;
56+ } ) ;
57+ } ,
58+ beforeDestroy ( ) {
59+ this . webmap = null ;
60+ }
61+ }
62+ }
63+
64+ Vue . component ( 'webmap' , webMapComponent ) ;
65+
66+ new Vue ( {
67+ el : '#app' ,
68+ data : {
69+ webMapOptions : {
70+ target : 'map' ,
71+ server : 'http://support.supermap.com.cn:8092'
72+ } ,
73+ } ,
74+ methods : {
75+ addLayersSucceeded ( e ) {
76+ return e . layers ;
77+ }
78+ }
79+ } ) ;
80+ </ script >
81+ </ body >
82+
83+ </ html >
0 commit comments