Loading a local .kml file using google maps?

前端 未结 4 2057
时光取名叫无心
时光取名叫无心 2020-12-04 11:27

I created a hello world program to load a local kml file (borrowed from google\'s docs):

var ctaLayer = new google.maps.KmlLayer(\"http://localhost:8080/kml/         


        
4条回答
  •  孤街浪徒
    2020-12-04 12:11

    Unfortunately you cannot use "localhost". You have two choices:

    1. place the kml on a publically available domain. (if google cannot access it, it won't work)
    2. Use geoxml3 which basically does what google does but allows you to downlaod and host the parser JS file youself. It will allow you to load a LOCALHOST KML and parse it out for you (objects accessible via JSON) (http://code.google.com/p/geoxml3/).

    Choice #1 might not be an option for those working on defense contracts and deal with sensitive information as the kml is sent to google in the background and rendered on the map.

提交回复
热议问题