【问题标题】:Thymeleaf with OpenLayers 4Thymeleaf 与 OpenLayers 4
【发布时间】:2018-11-27 15:25:15
【问题描述】:

我在模板中有这段代码:

 view: new ol.View({
                               center: ol.proj.fromLonLat([/*[[${center.longitude}]]*/, /*[[${center.latitude}]]*/]),
                           zoom: 14
                         })

这是对象的值:

center [ Coordinate [latitude=41.33434906005859, longitude=1.8457042932510377]]

但是当我看到模板的来源时,我看到了这个

view: new ol.View({
                               center: ol.proj.fromLonLat([[[${center.longitude}]], /*41.33434906005859*/]),
                           zoom: 14
                         })

【问题讨论】:

    标签: html spring-mvc spring-boot thymeleaf openlayers


    【解决方案1】:

    请先将值赋值给js变量。

    var centerLat = /*[[${center.longitude}]]*/;
    var centerLng = /*[[${center.latitude}]]*/;
    

    然后使用它。

     view: new ol.View({
            center: ol.proj.fromLonLat([centerLng, centerLat]),
            zoom: 5
        })
    

    here中找到工作代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-25
      • 1970-01-01
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      相关资源
      最近更新 更多