tags:

views:

7

answers:

0

The question I have is about Google Maps "FeatureData". I have got it working really well, so that when I click on the markers on my KML based map, the information pops up in a separate DIV.

What I would like to do is display something in the DIV which currently starts it's life empty until I click a marker. Have any of you done this before entirely through Javascript? I would like to pick maybe the last placemarker in the KML...

My current Javascript is below for your reference.....

<script type="text/javascript">
    function initialize() {
        var latlng = new google.maps.LatLng(51.35977664828087, 0.1153564453125);

        var myOptions = {
            zoom: 8,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        var ctaLayer = new google.maps.KmlLayer('http://dev.mysite.com/content/locations.kml', {suppressInfoWindows: true});
        ctaLayer.setMap(map);

        google.maps.event.addListener(ctaLayer, 'click', function (kmlEvent) {

            var text = kmlEvent.featureData.description;
            showInDiv(text);
        });


    function showInDiv(text) {
        var sidediv = document.getElementById('contentWindow');
        sidediv.innerHTML = text;
    }


    }


</script>