问题
I am just wondering if there is a possibility that my program can add/remove markers in the kml file that I just created?
For example, my KML file contains all the areas in a city where there is a reported case of flooding. After uploading the file and displaying it in the Google Maps through my website, a new case was reported. Is it possible to add that place in my website's "add area" field and update the KML file as well?
Thanks in advance!
回答1:
There are plenty of libraries out there for programatically updating KML. My current favorite is pyKML, but there's also libkml and a number of others. Or just as easily, KML is just XML markup so any libraries you have for reading/writing XML work fine.
If you're asking can it be done through the Google Maps API, no it can't. The KML rendering there happens server side and you don't get write access to a KML object through KMLLayer.
来源:https://stackoverflow.com/questions/9195355/changing-kml-files-contents