<template>
    <div>

        <div class="bkh">
            <div style="font-size:1.5rem;">polylineSets</div>
            <a href="//yuda-lyu.github.io/w-leaflet-vue/examples/ex-AppPLNPolylineSets.html" target="_blank" class="item-link">example</a>
            <a href="//github.com/yuda-lyu/w-leaflet-vue/blob/master/docs/examples/ex-AppPLNPolylineSets.html" target="_blank" class="item-link">code</a>
        </div>

        <div class="bkp">

            <div style="display:flex; padding-bottom:40px; overflow-x:auto;">

                <div style="position:relative;">
                    <WLeafletVue
                        style="width:800px; height:500px;"
                        :opt="opt"
                    ></WLeafletVue>
                </div>

                <div style="width:600px; min-width:600px; padding:0px 20px;">

                    <div style="border:1px solid #ddd;">
                        <div style="padding-left:5px; overflow-y:auto; height:500px;">
                            <div id="optjson" style="font-size:10pt;"></div>
                        </div>
                    </div>

                </div>

            </div>

        </div>

    </div>
</template>

<script>
import WLeafletVue from './components/WLeafletVue.vue'
import jv from 'w-jsonview-tree'

export default {
    components: {
        WLeafletVue,
    },
    data: function() {
        return {
            'opt': {
                center: [25, 121.58],
                zoom: 9,
                polylineSets: [
                    {
                        title: 'polylineSet A',
                        msg: 'msg from polylineSet A',
                        latLngs: [
                            [ //add p1
                                [24.96, 121.41], [25.11, 121.47], [25.06, 121.69], [24.99, 121.61], [24.95, 121.53], [24.96, 121.41]
                            ],
                            [ //add p2
                                [24.92, 121.60], [25.045, 121.75], [24.99, 121.79], [24.93, 121.74], [24.92, 121.60]
                            ],
                        ],
                        visible: true,
                    },
                    {
                        title: 'polylineSet B',
                        msg: 'msg from polylineSet B',
                        latLngs: [
                            [ //add p3
                                [24.971, 121.372], [24.976, 121.434], [24.937, 121.473], [24.918, 121.418], [24.971, 121.372]
                            ],
                            [ //add p4
                                [24.90, 121.14], [24.97, 121.09], [25.05, 121.177], [24.95, 121.32], [24.90, 121.14]
                            ],
                        ],
                        visible: false,
                    },
                ],
            },
            'action': [
            ],
        }
    },
    mounted: function() {
        let vo = this
        vo.showOptJson()
    },
    watch: {
        opt: {
            handler: function() {
                let vo = this
                vo.showOptJson()
            },
            deep: true,
        },
    },
    methods: {
        showOptJson: function() {
            let vo = this
            jv(vo.opt, document.querySelector('#optjson'), { expanded: true })
        },
    },
}
</script>

<style>
</style>
