代码之家  ›  专栏  ›  技术社区  ›  Vy Do

谷歌地图标记标签中显示错误UTF-8字符

  •  -1
  • Vy Do  · 技术社区  · 3 年前

    foo.ftl

    <script>
            function initMap() {
                const map = new google.maps.Map(document.getElementById("map"), {
                    zoom: 16,
                    center: {lat: 20.993514917846174, lng: 105.78660475957122},
                });
                // const labels = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                const labels = [
                    "The Light Trung Văn",
                    "Khu đô thị Mulbery Lane",
                    "Nhà thờ giáo xứ Phùng Khoang",
                    "Khỏe đẹp 24h"];
    
                const locations = [
                    { lat: 20.9935851166474, lng: 105.78857910579417 },
                    { lat: 20.986910834987295, lng: 105.78535398147808 },
                    { lat: 20.990339683019226, lng: 105.7922698253056 },
                    { lat: 20.996770381033244, lng: 105.79321396285934 }
                ];
    
                const markers = locations.map((location, i) => {
                    return new google.maps.Marker({
                        position: location,
                        label: labels[i % labels.length],
                    });
                });
    
                new MarkerClusterer(map, markers, {
                    imagePath:
                        "https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",
                });
    
                const ecolife = {lat: 20.993514917846174, lng: 105.78660475957122};
    
                // const map22 = new google.maps.Map(document.getElementById("map"), {
                //     zoom: 18,
                //     center: ecolife,
                // });
                // const marker = new google.maps.Marker({
                //     position: ecolife,
                //     map: map22,
                // });
            }
    
    
        </script>
    

    我看到网页的HTML源代码

    enter image description here

    在文本编辑器中编码

    enter image description here

    enter image description here

    0 回复  |  直到 3 年前
        1
  •  1
  •   Vy Do    3 年前

    这是FreeMarker的一个缺陷

    <#ftl encoding="utf-8">
    

    看见 https://freemarker.apache.org/docs/pgui_misc_charset.html#autoid_52