KML markers missing on Google Maps API v3: What

2019-07-22 05:23发布

I'm new to the Google Maps API v3 and have been closely reading the documentation.

My map loads fine, but it's not displaying the Placemarks I've set up in my KML file (http://hepac.ca/wp-content/mapping/wellnessnetworks.kml). The KML validates fine at FeedValidator and displays without issue in Google Earth, so I'm assuming it's a problem with my code below.

The placemarks were appearing at one point, but I must have accidentally deleted some crucial code. Thanks in advance for helping!

  function initialize() {

var mapcenter = new google.maps.LatLng(46.36209, -64.73145);
var mapOptions = { 
    zoom: 7,
    center: mapcenter,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
   };                

google.maps.visualRefresh = true;  

var map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);

var opt = { minZoom: 7, maxZoom: 9 }; // Sets minimum & maximum zoom level
map.setOptions(opt);

var ctaLayer = new google.maps.KmlLayer({
    url: 'http://hepac.ca/wp-content/mapping/wellnessnetworks.kml',
    preserveViewport: true,
});
ctaLayer.setMap(map);

}

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

2条回答
仙女界的扛把子
3楼-- · 2019-07-22 06:17

This is the code I'm using and it's working for me. Let me know if this helps.

map = new google.maps.Map(document.getElementById('googft-mapCanvas'), {
  center: new google.maps.LatLng(50.022, -88.73),
  zoom: 4,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});

layer = new google.maps.FusionTablesLayer({
  map: map,
  heatmap: { enabled: false },
  query: {
    select: "[COLUMN_FROM_YOUR_TABLE]",
    from: "[YOUR_KML_ID]",
    where: ""
  },
  options: {
    styleId: 2,
    templateId: 2
  }
});

google.maps.event.addDomListener(window, 'load', initialize);
查看更多
登录 后发表回答