防止android webview中的谷歌地图缓存

防止android webview中的谷歌地图缓存,android,google-maps,caching,webview,kml,Android,Google Maps,Caching,Webview,Kml,我正在使用本地html文件(资产文件夹)在我的WebView中加载谷歌地图。该地图有一个kml覆盖图。我面临的问题是,当kml文件更新时,相应的更改不会反映在我的WebView中。我还尝试删除这些文件,在这种情况下,地图仍然显示以前加载的覆盖图。所以我假设它与缓存有关。为了防止缓存,我尝试在html中使用清单,但没有成功。我的代码如下 wv_map.getSettings().setJavaScriptEnabled(true); wv_map.getSettings().se

我正在使用本地html文件(资产文件夹)在我的
WebView
中加载谷歌地图。该地图有一个kml覆盖图。我面临的问题是,当kml文件更新时,相应的更改不会反映在我的
WebView
中。我还尝试删除这些文件,在这种情况下,地图仍然显示以前加载的覆盖图。所以我假设它与缓存有关。为了防止缓存,我尝试在html中使用清单,但没有成功。我的代码如下

    wv_map.getSettings().setJavaScriptEnabled(true);

    wv_map.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

    wv_map.clearCache(true);

    wv_map.clearHistory();

    wv_map.loadUrl("file:///android_asset/content.html");
content.html是:

<!DOCTYPE html>

<html manifest="map.cache">

<head>

    <meta charset="utf-8">

    <title>KML Layers</title>

    <style>

        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }

        #map {
            height: 100%;
        }


        #map img {
            opacity: .4;
        }


        .gmnoprint a, .gmnoprint span {
            display:none;   //remove copyright and terms of use
        }

        .gmnoprint div {
            background:none !important;
        }

        .gm-style-mtc {
            display: none;  //remove satellite option
        }

    </style>

</head>


<body>

    <div id="map"></div>

    <script type="text/javascript">


            function initMap() {

                layer0 = new google.maps.KmlLayer(*MY_URL_TO_KML_FILE*,
                {
                    preserveViewport: true
                });


                var map = new google.maps.Map(document.getElementById('map'),{
                  zoom: 2,
                  center: {lat: 10, lng: 120},

                  streetViewControl: false  //remove the icon of person from the map
                });


                layer0.setMap(map);

            }

    </script>


    <script async defer
            src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap">
    </script>

</body>
最后,kml文件是:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">

  <Document>

    <GroundOverlay>

        <color>#7cff0000</color>

        <drawOrder>1</drawOrder>

        <Icon>
            <href>URL_TO_OVERLAY_IMAGE</href>
        </Icon>

        <LatLonBox>
          <west>90</west>
          <east>95</east>
          <south>-19</south>
          <north>25</north>
        </LatLonBox>

    </GroundOverlay>

 </Document>

</kml>

#7cff0000
1.
URL\u到\u覆盖\u图像
90
95
-19
25
我通过图标标签更新覆盖图像

谢谢。

的答案帮助解决了这个问题。我希望这将有助于面临同样问题的人。
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">

  <Document>

    <GroundOverlay>

        <color>#7cff0000</color>

        <drawOrder>1</drawOrder>

        <Icon>
            <href>URL_TO_OVERLAY_IMAGE</href>
        </Icon>

        <LatLonBox>
          <west>90</west>
          <east>95</east>
          <south>-19</south>
          <north>25</north>
        </LatLonBox>

    </GroundOverlay>

 </Document>

</kml>