简体   繁体   中英

Can I add a KML file in GoogleMaps with a local path in JavaScript?

Below is my JavaScript code.
Please localize my path thrown by my open .kml file in GoogleMaps:

function initMap() {

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 11,
      center: {lat: 23.026261,  lng: 72.566872}
    });     

    var ctaLayer = new google.maps.KmlLayer({
     url: 'http://exaple.com//aa.kml',
      map: map
    });
}

My questions are:
Can I add a local path in JavaScript?
Can I add a dynamic change to a .kml file in JavaScript?

Google processes KML layers on their servers and returns tile imagery for KML layers you provided. In order to process KML on server side they need upload your KML file to their server. That means you cannot use URL that is not accessible publicly from the web, so local path won't work.

Unfortunately, you cannot use local paths in KML layers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM