Adding KML problem

53 views
Skip to first unread message

J.M.

unread,
Mar 5, 2012, 9:50:35 PM3/5/12
to google-map...@googlegroups.com
Hello,
 
I have added a google maps api to a blog site, and works fine.  But now I would like to add a KML file (from a public server) and it doesn't work. Any ideas to fix the code in blue?
 
 
function initialize() { 
    var mapOptions = { 
      zoom: <?php get_option_tree('zoom', '', true); ?>, 
      mapTypeId: google.maps.MapTypeId.<?php get_option_tree('map_type', '', true); ?>, 
      center: stockholm 
    }; 
 
    map = new google.maps.Map(document.getElementById("map_canvas"), 
            mapOptions);  

    var kml = new GGeoXml("http://www.mydomain.com/name.kml");
    map.addOverlay(kml)
  }

geoco...@gmail.com

unread,
Mar 6, 2012, 1:04:28 AM3/6/12
to Google Maps JavaScript API v3
On Mar 5, 6:50 pm, "J.M." <jordim...@gmail.com> wrote:
> Hello,
>
> I have added a google maps api to a blog site, and works fine.  But now I
> would like to add a KML file (from a public server) and it doesn't work.
> Any ideas to fix the code in blue?

What code in blue?

>
>
> > function initialize() {
> >     var mapOptions = {
> >       zoom: <?php get_option_tree('zoom', '', true); ?>,
> >       mapTypeId: google.maps.MapTypeId.<?php get_option_tree('map_type',
> > '', true); ?>,
> >       center: stockholm
> >     };
>
> >     map = new google.maps.Map(document.getElementById("map_canvas"),
> >             mapOptions);
>
> >     var kml = new GGeoXml("http://www.mydomain.com/name.kml");

That file doesn't exist.

If you are using the v3 API, GGeoXml doesn't exist either (which
should be obvious from the javascript errors). Try using the v3
equivalent (KmlLayer).


> >     map.addOverlay(kml)

Also a v2 method, are you using v3 of the Google Maps Javascript API?
Or v2, if so that has a separate group:
http://groups.google.com/group/google-maps-api


-- Larry

> >   }
Reply all
Reply to author
Forward
0 new messages