Novice help KML

25 views
Skip to first unread message

Graeme Armitage

unread,
Dec 21, 2011, 6:33:32 AM12/21/11
to google-map...@googlegroups.com
Have used a demo script to place a  KMZ file  the script get the content  to display in an area to the side of the map I have tried various option and sample to  try and get the overlays to function as normal  but none seem to work  other than this script   the others  show  the map and overlays but  will not click 


Appreciate any help

<script type="text/javascript">
function initialize() {
  var myLatlng = new google.maps.LatLng(53.485683554769125, -2.1006202697753906);
  var myOptions = {
    zoom: 14,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.HYBRID
  };

  var map = new google.maps.Map(
      document.getElementById("map_canvas"),
      myOptions);

  var nyLayer = new google.maps.KmlLayer(
      'http://www.stpetersfield1.zee.com/StPetersfield.kmz',
      {  suppressInfoWindows: true,
         map: map,
         preserveViewport: true
		 });

  google.maps.event.addListener(nyLayer, 'click', function(kmlEvent) {
    var text = kmlEvent.featureData.description;
    showInContentWindow(text);
  });

  function showInContentWindow(text) {
    var sidediv = document.getElementById('content_window');
    sidediv.innerHTML = text;
  }
}
</script>

Rossko

unread,
Dec 21, 2011, 9:24:34 AM12/21/11
to Google Maps JavaScript API v3
>  but none
> seem to work  other than this script   the others  show  the map and
> overlays but  will not click

I don't understand. You have a script that does what you want? Some
other script that is a secret from us does not do the same thing?
What is it you want help with?

Graeme Armitage

unread,
Dec 21, 2011, 4:23:41 PM12/21/11
to google-map...@googlegroups.com
Hi The script I have works, but puts the  content of the three markers from the kml file in a panel at the side of the map I am trying to get the content of the three markers  to appear in pop up overlays like  they do Google earth  or like normal makers do  in google maps.
Have tested other demo scripts using my kml from this google site, although  they all display the map and markers, but they do not  display the information associated the yellow makers.

The simpler demos on the site do not have an event handler but  seem to operate  some popups.  As these scripts would not work fully with my kml  overlay, I am assuming that  some kind of event handler is necessary to make the makers activate as they are contained with  in the kml file

Being a complete novice  I was looking for some help  I assumed that the event handler  from the script was necessary to make the makers activate  but needs directing to a standard overlay. I have no idea how to go about this.

So at a guess I am asking  how to direct the content  activated  by the event listener  can be re directed back to a normal pop up overlay  as opposed to the content_window div in the demo script. I accept that my assumptions may be totally incorrect. And that I am showing the script that come closest to working with the kml files i have.  It is likely that for the kml file i have, it may be totally the wrong script  to be using. 

Rossko

unread,
Dec 21, 2011, 6:12:30 PM12/21/11
to Google Maps JavaScript API v3
> Hi The script I have works, but puts the  content of the three markers from
> the kml file in a panel at the side of the map I am trying to get the
> content of the three markers  to appear in pop up overlays like  they do
> Google earth  or like normal makers do  in google maps.

Okay, that's the default behaviour. The example you are using now
deliberately suppresses that and does something else instead. Don't
work from that example.

> Have tested other demo scripts using my kml from this google site

Can't help, no idea which scripts you have tried or even which site.

> The simpler demos on the site do not have an event handler but  seem to
> operate  some popups.

Yes, that's the default KmlLayer behaviour with no special event
handling - the API displays <description> content for you on click
unless you instruct it not to.

>  As these scripts would not work fully with my kml

Why do you think that? I think the simplest KmlLayer example in the
documentation should do you
http://code.google.com/apis/maps/documentation/javascript/layers.html#KMLLayers

Graeme Armitage

unread,
Dec 21, 2011, 7:27:58 PM12/21/11
to google-map...@googlegroups.com
Thank you, those were the scrips I was  trying  but  had not fond them via that page  reading  through that page I found,  what i was doing wrong and some of my assumptions as usual were incorrect the problem was with the KML layer options.   All is working correctly  so thanks again much appreciated  
Reply all
Reply to author
Forward
0 new messages