隐式地图定位

时间:2014-09-29 10:02:10

标签: android google-maps

我使用静态地图网址显示位置,我使用隐式定位问题是它显示了ecaxt位置但没有完全显示该特定位置的地址。我已粘贴以下代码: -

private void loadMap(){

    Context context=getActivity();
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    int width = metrics.widthPixels;
    int height = metrics.heightPixels;
    /*WindowManager wm = (WindowManager) mContext
            .getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;*/
    String mapUrl="http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&size="+ width
            / 2
            + "x"
            + height/2+"&markers=size:mid%7Ccolor:red%7CCarrollton+Springs+Parker+Rd+TX+United+States";
    /*String mapUrl = "http://maps.googleapis.com/maps/api/staticmap?center=33.045497,-96.868482&zoom=6&size="
            + width
            / 2
            + "x"
            + height
            / 2
            + "&markers=size:mid%7Ccolor:red%7CCarrollton+Springs+Parker+Road+Carrollton+TX+United+States";*/
    new MapDownloader().execute(mapUrl);

}

private class MapDownloader extends AsyncTask<String, Void, Bitmap> {

    @Override
    protected Bitmap doInBackground(String... params) {
        // TODO Auto-generated method stub
        return getGoogleMapThumbnail(params[0]);
    }

    private Bitmap getGoogleMapThumbnail(String url) {
        Bitmap bmp = null;
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet request = new HttpGet(url);

        InputStream in = null;
        try {

            in = httpclient.execute(request).getEntity().getContent();
            bmp = BitmapFactory.decodeStream(in);

            in.close();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return bmp;
    }

0 个答案:

没有答案