return $r; } /** * @param int $page 页数 * @param int $pagesize 每页显示数量 * @return mixed */ function link_find($page = 1, $pagesize = 100) { $arr = link__find($cond = array(), array('rank' => -1), $page, $pagesize); return $arr; } /** * @param $id * @return bool 返回FALSE失败 TRUE成功 */ function link_delete($id) { if (empty($id)) return FALSE; $r = link__delete(array('id' => $id)); link_delete_cache(); return $r; } //--------------------------kv + cache-------------------------- /** * @return mixed 返回全部友情链接 */ function link_get($page = 1, $pagesize = 100) { $g_link = website_get('friends_link'); if (empty($g_link)) { $g_link = link_find($page, $pagesize); $g_link AND website_set('friends_link', $g_link); } return $g_link; } // delete kv and cache function link_delete_cache() { website_set('friends_link', ''); return TRUE; } ?>javascript - Leaflet.Draw edit and delete button not working - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Leaflet.Draw edit and delete button not working - Stack Overflow

programmeradmin1浏览0评论

I'm using Leaflet Draw to let users draw a polyline in a map in order to measure sections. First step is to use Leaflet.Draw to let users draw the line. Leaflet.Draw includes a delete and edit button. These buttons are, however not working.

I've (re)used working code from other projects to create the draw control and pass it a FeatureGroup and editable layers.

// My draw Toolbar
var drawnItems = new L.FeatureGroup()
map.addLayer(drawnItems)
var drawControl = new L.Control.Draw({
  draw:{polygon: false,
        marker: false,
        circlemarker: false,
        rectangle: false,
        circle: false,
    },
  edit: {
    featureGroup: drawnItems
  }
});

map.addControl(drawControl);
map.on(L.Draw.Event.CREATED, function (e) {
   var layer = e.layer;
   map.addLayer(layer);
});

Seems like I'm linking the feature group correctly, but for some reason the delete and edit are not working :(

I'm using Leaflet Draw to let users draw a polyline in a map in order to measure sections. First step is to use Leaflet.Draw to let users draw the line. Leaflet.Draw includes a delete and edit button. These buttons are, however not working.

I've (re)used working code from other projects to create the draw control and pass it a FeatureGroup and editable layers.

// My draw Toolbar
var drawnItems = new L.FeatureGroup()
map.addLayer(drawnItems)
var drawControl = new L.Control.Draw({
  draw:{polygon: false,
        marker: false,
        circlemarker: false,
        rectangle: false,
        circle: false,
    },
  edit: {
    featureGroup: drawnItems
  }
});

map.addControl(drawControl);
map.on(L.Draw.Event.CREATED, function (e) {
   var layer = e.layer;
   map.addLayer(layer);
});

Seems like I'm linking the feature group correctly, but for some reason the delete and edit are not working :(

Share Improve this question asked Apr 5, 2019 at 8:49 Kaz VermeerKaz Vermeer 1451 silver badge10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You're adding the drawn items to map but they should be added to the layer pointed by edit.featureGroup if you want to edit them, i.e drawnItems:

map.on(L.Draw.Event.CREATED, function (e) {
    var layer = e.layer;
    drawnItems.addLayer(layer);
});

Here's a demo https://jsfiddle/4g5u071r/

发布评论

评论列表(0)

  1. 暂无评论