无法将图标添加到标记,地图Android版V2

编程入门 行业动态 更新时间:2024-10-15 22:29:47
本文介绍了无法将图标添加到标记,地图Android版V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

下面就是我如何添加标记地图

Here is how i am adding marker to map

map.addMarker(new MarkerOptions() .position(model.getLatLongfromService()) .title(model.getCoupon_name()) .snippet(model.getCoupon_id()) .icon(BitmapDescriptorFactory.fromFile(DataHolder.imageUrl + model.getCoupon_image())));

  • 我越来越coupon_image格式如下: www.xyz/coupon21 .JPG **

    我收到此错误当u运行我的应用程序。

    I am getting this error when u run my app.

    java.lang.IllegalArgumentException异常:文件 test.xyz由Matchi提供回到/上传/ company_logo /采样徽标110x60.jpg 包含路径分隔符

    java.lang.IllegalArgumentException: File test.xyz.de/uploads/company_logo/sample-logo-110x60.jpg contains a path separator

    谁能帮我了解的问题是什么?

    Can anyone help me to understand what the problem is ?

    谢谢,拉克什

    Thanks, Rakesh

    推荐答案

    我认为这个问题是该方法BitmapDesc​​riptorFactory.fromFile使用参数字符串的文件名,从而重新presents的文件名(图像)加载。您提供的图像的HTTP URL( test.xyz.de/uploads /company_logo/sample-logo-110x60.jpg )代替它。

    I think the problem is that method BitmapDescriptorFactory.fromFile uses parameter String fileName, which represents name of the file(image) to load. You supply image's http url (test.xyz.de/uploads/company_logo/sample-logo-110x60.jpg) instead of it.

    您可能需要先下载图像,然后使用BitmapDesc​​riptorFactory.fromBitmap;

    You probably need to download the image first and then use BitmapDescriptorFactory.fromBitmap;

    编辑:要下载图片,你可以使用一些AsyncTask的像这样的例子:

    To download image, you can use some AsyncTask like this for example:

    AsyncTask<String, Void, Bitmap> loadImageTask = new AsyncTask<String, Void, Bitmap>(){ @Override protected Bitmap doInBackground(String... params) { Bitmap bmImg = null; try { URL url = new URL(params[0]); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); } catch (IOException e) { e.printStackTrace(); bmImg = null; } return bmImg; } @Override protected void onPostExecute(Bitmap result) { super.onPostExecute(result); // TODO: do what you need with resulting bitmap - add marker to map } };

    这时别忘了适当的参数来执行的AsyncTask - 包含图像的URL字符串数组下载:

    then don't forget to execute asynctask with proper parameter - String array containing url of image to download:

    loadImageTask.execute(new String[]{yourImageUrl});

更多推荐

无法将图标添加到标记,地图Android版V2

本文发布于:2023-06-01 18:58:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/422866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图标   标记   地图   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!