Cropping Google Map - android

Is it possible to crop the Google Map before integrating it into an application?
For example, my city will be the only area visible when I launch the application.

It is not possible to crop an area or any part of Maps, you can show your area initially when user view your app & disable navigating within the map by setClickable(false);
mapView.setBuiltInZoomControls(false);
List<overlay> mapOverlays = mapView.getOverlays();
GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
OverlayItem overlayitem = new OverlayItem(point, "This is my area");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
MapController mapController = mapView.getController();
mapController.animateTo(point);
mapController.setZoom(6);
where latitudeE6, longitudeE6 is your area's lat & Long

Related

Set multiple marker in osmdroid

Hi everyone I'm using osmdroid in my application. I have a list of Latitude and Longitude sets and want to show them on the map and each one should be clickable means when I click on one of them it opens new specific activity. so how i suppose to do that ?
I want to do something just like this :
Sadly i couldn't find much information about working with osmdroid so any help would be appreciated.
This is how i used osmdroid map
mapView.setTileSource(TileSourceFactory.MAPNIK);
IMapController mapController = mapView.getController();
mapController.setZoom(9.5);
GeoPoint startPoint = new GeoPoint(34.796830, 48.514820);
mapController.setCenter(startPoint);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
And this is overlays with geopoints :
List<OverlayItem> mItem = new ArrayList<OverlayItem>();
Drawable mMarker = this.getResources().getDrawable(R.drawable.marker_default);
GeoPoint point;
if (nearestDiscountsList.size()>0) {
for (int i = 0; i < nearestDiscountsList.size(); i++) {
point = new
GeoPoint(Double.parseDouble(nearestDiscountsList.get(i).getLatitude()),
Double.parseDouble(nearestDiscountsList.get(i).getLongitude()));
OverlayItem overlayItem = new OverlayItem("Here",
"sampleDescription", point);
overlayItem.setMarker(mMarker);
mItem.add(overlayItem);
}
}
But I do not know where to add these ):
Even any sample code about this will do the job.

How can I show my location on google maps in android

I have a google maps app that takes an array of points and puts them on a map. I want to add the little blue dot that moves as the user moves around. I haven't found any tutorials on how to do this. Here is an example of what I need
Note that the blue dot also has a blue ring that pulsates and it follows you when you start walking.
Thanks
EDIT I have found the function drawMyLocation, however I do not know where to place it. Here is my map activity and my itemized overlay (I am using a balloon itemized overlay to create the popup dialog effect)
MapView mapView = (MapView) findViewById(R.id.mapView);
List<Overlay> mapOverlays = mapView.getOverlays();
for (int i = 0; i < mList.size(); i++) {
Drawable drawable = null;
for (int k = 0; k < ImTracking.pList.size(); k++) {
if (mList.get(i).getId()
.equals(ImTracking.pList.get(k).getid())) {
mList.get(i).setName(
ImTracking.pList.get(k).getName());
if (mList.get(i).getMostRecent()) {
drawable = Maps.this.getResources()
.getDrawable(
pincolorstar[ImTracking.pList
.get(k).getPosition()]);
} else {
drawable = Maps.this
.getResources()
.getDrawable(
ImTracking.pincolors[ImTracking.pList
.get(k).getPosition()]);
}
}
}
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(
drawable, mapView);
GeoPoint myPoint = new GeoPoint((int) (mList.get(i)
.getLatitude() * 1E6), (int) (mList.get(i)
.getLongitude() * 1E6));
OverlayItem overlayitem = new OverlayItem(myPoint, mList
.get(i).getName(), mList.get(i).getTime());
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
The above part adds all the pins to the map, the next part is where I attempt to add the mylocation overlay
MyLocationOverlay myLocationOverlay=new MyLocationOverlay(Maps.this, mapView);
myLocationOverlay.enableMyLocation();
mapOverlays.add(myLocationOverlay);
MapController mc = mapView.getController();
mc.zoomToSpan(Math.abs(maxLat - minLat),
Math.abs(maxLon - minLon));
mc.animateTo(new GeoPoint((maxLat + minLat) / 2,
(maxLon + minLon) / 2));
} catch (Exception e) {
e.printStackTrace();
}
Just adding myLocationOverlay to mapOverlays does not display the blue dot.
You might want to see MyLocationOverlay and see if that can fit into your requirement
Sample illustration below:
List overlaysoverlays = mapView.getOverlays();
// "this" refers to your activity
MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
myLocationOverlay.enableMyLocation();
overlays.add(myLocationOverlay);

Map values on Google map android

If there are values for Longitude and latitude how to map these values on GoogleMaps.Please give me links to this..
Ex: Longitude:12.93434334 Latitude:144.12121212
How to map these values on google map and get the position
If you mean to set/display map at particular coordinates you need to get MapController from MapView and set/animate to center you wish.
MapView view = (MapView)findViewById(id);
MapController controller = view.getController();
GeoPoint gp = new GeoPoint(lat, lon);
controller.setCenter(gp);
// controller.animateTo(gp); alternatively...

how to show multi color map overlays or pins in android on google map?

friends,
right now i am showing list of map overlays on google map using following code
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.balloon);
itemizedOverlay = new MarkerItemizedOverlay(drawable,this);
GeoPoint point;
OverlayItem overlayitem;
for (DalMapSearch t : Sr)
{
if(t != null)
{
point = new GeoPoint((int) (t.getLati() * 1E6), (int) (t.getLongi() * 1E6));
overlayitem = new OverlayItem(point, heading, t.getAd_text()+", "+t.getLocation()+"##"+t.getAd_id());
itemizedOverlay.addOverlay(overlayitem);
}
}
mapOverlays.add(itemizedOverlay);
// marker code goes here
mc.animateTo(myLocation);
mc.setZoom(12);
mapView.invalidate();
so in such a scenario balloon is displayed i want to show other images too depened upon category or a if statement.
any one guide me how can i show different images as a map overlay? for example images are imageA,ImageB,ImageC
any help would be appreciated.
GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue());
drawable = this.getResources().getDrawable(R.drawable.marker);
itemizedOverlay = new MyItemizedOverlay(drawable);
OverlayItem overlayItem = new OverlayItem(point, "", "");
itemizedOverlay.addOverlay(overlayItem);
mapOverlays.add(itemizedOverlay);
GeoPoint point2 = new GeoPoint(lt2.intValue(),long2.intValue() );
// All "B"s
drawable = this.getResources().getDrawable(R.drawable.icon);
itemizedOverlay = new MyItemizedOverlay(drawable);
OverlayItem overlayItem1 = new OverlayItem(point2, "", "");
itemizedOverlay.addOverlay(overlayItem1);
mapOverlays.add(itemizedOverlay);

How to to make 2 MapView on one Activity?

Is it possible to make 2 MapView on one Activity ?
If so, How to make it ?
I've tried but no luck.
Thanks in advance.
The short answer is no.
Currently Android supports only one MapView per MapActivity.
yes possible, I used this code for two different kinds of maps------ 1. for getting gps location------2. for getting some location when it is searched by its area/city/country name. The code is,
public void mapDisplay(double lat, double lng, int arg){
if(arg == 1){
mapView = (MapView)findViewById(R.id.map_view);
}
else if (arg ==2 ){
mapView = (MapView)findViewById(R.id.map_view2);
}
mapView.setBuiltInZoomControls(true);
//mapView.setStreetView(true);
//mapView.setTraffic(true);
//mapView.setSatellite(true);
// to display the pin point
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay(drawable, this);
GeoPoint point = new GeoPoint((int) (lat * 1E6), (int)(lng * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "", "");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
mapView.getController().setZoom(18);
mapView.getController().setCenter(point);
mapView.getController().animateTo(point);
mapView.invalidate();
}
Note: Make sure that you have set the ContentViews before calling this method and
int arg
is used here to indicate that which mapView is going to be called.....I used

Categories

Resources