How to create a google map with kml layer overlay dynamically

前端 未结 1 879
予麋鹿
予麋鹿 2020-12-20 07:17
function initialize() {
    var myOptions = {
      center: new google.maps.LatLng(23.71181,90.407467),
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP         


        
相关标签:
1条回答
  • 2020-12-20 07:31

    Yes, it is possible to generate a new KML file server-side (PHP) and then tell JavaScript to load a new KmlLayer using the URL that will generate the KML content. Note that the KML URL:

    • must be publicly accessible, since Google servers need to download it
    • will be cached by Google servers, serving a different content at the same URL won't refresh it

    To overcome this caching, just add some random clatter to the URL. However, be aware caching is there to make it fast. You can't have both "super-fast KML" and "real-time fresh data" at once. Also, keep an eye on your own server's response times for KML URLs, the faster the better.

    0 讨论(0)
提交回复
热议问题