Google Fusion Map Info Window Not Formatted

2019-02-28 10:47发布

问题:

I have created a Google Fusion Map with 2 layers. All appears to be working correctly with 1 exception.

I have formatted the Info Window of both layers using the Google Fusion Table tool. However, the Info Window on layer 1 is not appearing as specified with the code below. It works fine in the Google Fusion Table tool itself.

Can anyone spot what I've done wrong? Thanks.

    <meta charset="UTF-8">
    <title>Smithfield Foods UK</title>
    <link rel="stylesheet" type="text/css" media="all" href="FusionMapTemplate.css" />

    <script type="text/javascript"
        src="http://maps.google.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">

        function initialize() {
            var defaultZoom = 10;
            var defaultCenter = new google.maps.LatLng(52.6500, 1.2800)
            var locationColumn = 'geometry'

            var map = new google.maps.Map(document.getElementById('map-canvas'), {
                center: defaultCenter,
                zoom: defaultZoom,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });

            var infoWindow = new google.maps.InfoWindow();

            // Initialize the first layer
            var FirstLayer = new google.maps.FusionTablesLayer({
                query: {
                select: 'geometry',
                from: '1hpGzmMBg8bDgPOGrAXvc0_QVLSBqQ0O5vpLbfUE'
                },
                map: map,
                styleId: 3,
                templateID: 5,
                suppressInfoWindows: true
            });
            google.maps.event.addListener(FirstLayer, 'click', function(e) {windowControl(e, infoWindow, map);
            });

            // Initialize the second layer
            var SecondLayer = new google.maps.FusionTablesLayer({
                query: {
                    select: 'PostCode',
                    from: '1RrCcRC-1vU0bfHQJTQWqToR-vllSsz9iKnI5WEk'
                },
                map: map,
                styleId: 2,
                templateId: 2,
                suppressInfoWindows: true
            });
            google.maps.event.addListener(SecondLayer, 'click', function(e) {windowControl(e, infoWindow, map);
            });
        }   

        // Open the info window at the clicked location
        function windowControl(e, infoWindow, map) {
            infoWindow.setOptions({
                content: e.infoWindowHtml,
                position: e.latLng,
                pixelOffset: e.pixelOffset
            });
            infoWindow.open(map);
        }

        google.maps.event.addDomListener(window, 'load', initialize);

    </script>
</head>

<body>
    <div id="map-canvas"></div>

</body>

回答1:

the issue:

templateID: 5,
//-------^

the D has to be lowercase