I am trying to create a ImageView
with help of MapView
something like in pic:
Guys please give me some idea how to do this.
I am trying to create a ImageView
with help of MapView
something like in pic:
Guys please give me some idea how to do this.
If you want a static map, you can just do the same as me:
http://maps.google.com/maps/api/staticmap?center=-15.800513%2C-47.91378&zoom=16&format=png&maptype=roadmap&mobile=false&markers=|color:%23128DD9|label:Marker|-15.800513%2C-47.91378&size=1000x400&key=&sensor=false
Change the parameters
?center=
which will tell you where the center of the image shoud
belabel:Marker
The position where the marker should appear.To load this image to an ImageView
:
public static Bitmap loadBitmap(String url) {
Bitmap bitmap = null;
InputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new URL(url).openStream(), IO_BUFFER_SIZE);
final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
copy(in, out);
out.flush();
final byte[] data = dataStream.toByteArray();
BitmapFactory.Options options = new BitmapFactory.Options();
//options.inSampleSize = 1;
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,options);
} catch (IOException e) {
Log.e(TAG, "Could not load Bitmap from: " + url);
} finally {
closeStream(in);
closeStream(out);
}
return bitmap;
}
This method will return a Bitmap
to set this Bitmap
in the ImageView
just do like this:
ImageView img = (ImageView)findViewById(R.id.imageView1);
Bitmap b = loadBitmap(urlToTheImage);
img.setImageBitmap(b);
I'm not exactly sure what you mean, but from the looks of it you want the Google Static Maps API.
https://developers.google.com/maps/documentation/staticmaps/
This will generate an image of a map when you give it the latitude, longitude etc. You can then use this in an ImageView as you require.
The advantage is that you don't have to create an expensive MapView, but it will not be interactive