SkAndroidCodec :: NewFromStream返回null

时间:2017-04-18 11:31:51

标签: java android google-maps tile wms

我正在开发Android应用程序。我一直在Android监视器上得到它,而tileprovider在地图上平铺wms。

public class TileProviderFactory {
// return a geoserver wms tile layer
static TileProvider getTileProvider(final String url) {
    TileProvider tileProvider = new WMSTileProvider(256,256) {
    Bitmap image;
        @Override
        public synchronized URL getTileUrl(int x, int y, int zoom) {

            double[] bbox = getBoundingBox(x, y, zoom);
            String s;
            if (zoom > 15) {                    
                s = url + "%26bbox%3D" + String.valueOf(bbox[MINX]) + "%2C"+ String.valueOf(bbox[MINY]) +
                          "%2C"+ String.valueOf(bbox[MAXX]) + "%2C"+ String.valueOf(bbox[MAXY]) ;

            }else{
                s = "";
            }

            URL url = null;

            try {
                url = new URL(s);

                HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
                // Fetch and set cookies in requests
                CookieManager cookieManager = CookieManager.getInstance();
                String cookie = cookieManager.getCookie(connection.getURL().toString());
                if (cookie != null) {
                    connection.setRequestProperty("Cookie", cookie);
                }
                InputStream inputStream = connection.getInputStream();
                image = BitmapFactory.decodeStream(inputStream);
                inputStream.close();

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return url;

        }
    };

    return tileProvider;
}
}

这是我的代码:

http

当我删除cookie时,没有任何改变。我认为当wms平铺时cookie不能正常工作。您有什么推荐的吗?我能做什么? 感谢。

0 个答案:

没有答案