88</template >
99
1010<script setup lang="ts">
11- import { Component , createApp , h , ref , watch } from ' vue' ;
11+ import { ref , watch } from ' vue' ;
12+ import { createMapControl , createMapPopup } from ' ./utils' ;
13+
1214import Map from ' ../../packages/maplugin-maplibre/demo/Map.vue' ;
1315import Measurer from ' ./components/features/Measurer.vue' ;
1416import FeatureCollectionEditor from ' ./components/features/FeatureCollectionEditor.vue' ;
1517import ShowEditorButton from ' ./components/features/ShowEditorButton.vue' ;
1618import Data from ' ./components/features/Data/Data.vue' ;
19+ import ToggleButton from ' ./components/base/ToggleButton.vue' ;
1720
1821import { DrawManager , GeoJSONLayerManager , MeasureManager , TIdentityGeoJSONFeature , MiddleButtonRoate , VertexEditor , useCamera } from ' ../../packages/maplugin-maplibre' ;
1922import { StoreEditor } from ' ./stores' ;
@@ -93,19 +96,21 @@ function handleMapLoaded(map: maplibregl.Map) {
9396 drawManager .id_layer_line ,
9497 drawManager .id_layer_line_circle ,
9598 drawManager .id_layer_point ,
96- drawManager .id_layer_point_symbol ], ({ features }) => {
99+ drawManager .id_layer_point_symbol ], ({ features , lngLat }) => {
97100 if (drawManager .drawing || ! features || features .length === 0 ) return ;
98101 const f = glManager .query ((features [0 ].properties as any )[' id' ]);
99102 if (f ) {
100- glManager .setFeatureHidden (f .properties .id );
103+ // glManager.setFeatureHidden(f.properties.id);
104+
105+ // vertexEditor.setFeature(f, (id, g) => {
106+ // glManager.clearFeatureHidden(id);
101107
102- vertexEditor .setFeature (f , (id , g ) => {
103- glManager .clearFeatureHidden (id );
108+ // const featrue = glManager.query(id)!;
109+ // featrue.geometry = g;
110+ // glManager.update(featrue);
111+ // });
104112
105- const featrue = glManager .query (id )! ;
106- featrue .geometry = g ;
107- glManager .update (featrue );
108- });
113+ createMapPopup (map , lngLat , ToggleButton , {content:" 123" , defaultActive: false });
109114 }
110115 });
111116
@@ -118,32 +123,7 @@ function handleMapLoaded(map: maplibregl.Map) {
118123 createMapControl (map , Measurer , { measureManager }, ' top-left' );
119124}
120125
121- function createMapControl(map : maplibregl .Map , component : Component , data ? : Record <string , unknown >, position : maplibregl .ControlPosition | " top-center" | " bottom-center" = ' top-right' ) {
122- const div = document .createElement (' div' );
123- div .classList .add (" maplibregl-ctrl" );
124- createApp (component , data ).mount (div );
125-
126- if (position !== ' top-center' && position !== " bottom-center" )
127- map .addControl ({
128- onAdd() {
129- return div ;
130- },
131- onRemove() {
132- div .remove ();
133- }
134- }, position );
135-
136- else {
137- let container = document .querySelector (` .maplibregl-ctrl-${position } ` );
138- if (! container ){
139- container = document .createElement (' div' );
140- container .classList .add (` maplibregl-ctrl-${position } ` );
141- map ._controlContainer .append (container );
142- }
143126
144- container .append (div );
145- }
146- }
147127 </script >
148128
149129<style scoped>
0 commit comments