I try to offer 3 display modes to users of my app:
Traffic View (the standard view as on every printed map)
Satellite View (aerial) and
StreetView (3D, as done with the infamous Google Car)
I can set 'Standard' traffic view with
mapView.setSatellite(false);
mapView.setTraffic(true);
Satellite view with
mapView.setSatellite(true);
but
mapView.setStreetView(true);
doesn't do anything, even if I can get StreetView at the location checking with maps.google.com and a followup check for mapView.isStreetView() returns TRUE.
Can anyone help me out?
setStreetView(true) should load a tile set showing streets where StreetView data is available. It will not, however, actually display StreetView itself -- that is a separate application. You can launch StreetView, for devices that have it, for a given location by using a specific Intent structure. However, you cannot embed StreetView in your own app at this time.
Related
I am developing an application in which I need to use maps offline. I'm using osmdroid and osmbonuspack
I have implemented code to display user's current location. And display boundary by importing KML content.
How can I set alarm to notify user, when user come closer(about 50m-100m) to that boundary?Click to see the image
You can buffer the area by (50m, 100m) and use LocationManager #addProximityAlert() to set a trigger.
I am working on custom map app and i want to use google map tiles for background ? There is one class TileProvider in api but i don't know how to initialize it every time i try it goes something like this ?
TileProvider tileProvider=new TileProvider() {
#Override
public Tile getTile(int i, int i2, int i3) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
};
how to override getTile function to get tiles from google map server?
Any example will be appreciated ?I know getTile function need x,y and zoom value to return tile.
So quick answer is that you can get the Google Map tiles from the following URL:
http://mt1.google.com/vt/lyrs={t}&x={x}&y={y}&z={z}
Where {t} is the type of map (satellite, road, hybrid, etc) and the other attributes are specifying the coordinates and zoom level.
The possible values for {t} are as follows:
Default - m
Roads only - h
Roads simplified - r
Satellite - s
Satellite hybrid - y
Terrain - t
Terrain hybrid - p
That being said you do want to make sure what you're doing is NOT a violation of the terms & services. Specifically Google WILL allow you to cache their tiles provided that you are doing so ONLY in order to improve performance and that you delete their tiles at least every 30 days, and finally you don't pull down their tiles in an attempt to make your own mapping service.
You may want to read the Google Maps Terms of Service - https://developers.google.com/maps/terms - specifically section 10.1.1
I am looking to figure out how I can replicate the follow current location feature that exists in Maps on Android (and iPhone) using the Google Maps external library. The way the feature works in Maps is that when you press the button it begins panning with your location until you touch (and/or move) the map. Using the following I have been able to get my app to keep the current location on the screen but not keep the current location in the center of the screen (it pans when the location gets near the edge of the screen whereas Maps keeps it in the center the whole time):
butMapCurrentLocation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
runOnUiThread(new Runnable() {
public void run() {
mapController.animateTo(myLocationOverlay.getMyLocation());
}
});
}
});
I also tried setCenter rather than animateTo and they seem to have the same effect.
Additionally it is worth noting I need to be able to stop this function that keeps the location in the center (such as when another button is pressed or the map is touched). The Runnable above doesn't stop right away and I cannot get it to stop properly when requested even when using .cancel as discussed here: Android: How do I stop Runnable?
There is no official way yet to do that in Google Maps v2.
You can do what you want however. There is two things you have to do:
Register for location updates from some LocationProviders (eg gps) to get the user's location. When you get the location animate map to the new location.
Stop this when the user moved the map.
So doing 1. is easy, doing 2. is not possible officially with the Maps v2 api. Look at this issue for more details.
The workaround suggested there is to create your own MapView (extend the original MapView) and override it's dispatchTouchEvent method. There you can catch any touch events and can detect if the user touched/moved the map.
At middle of 2011 set mapView.setSattelite(true) will only show satellite view, but recently we find the same set will also show with roads and names above satelliete view.
May be it's very useful in other country, but in China, when add roads and names above satelliete view, the roads are not on the right position.
Can some one tell me how to remove roads and names above satelliete view?
How to show satellite view of Android mapview only.
I read Class MapView:
setSatellite(boolean on)
Sets the map mode to "satellite" mode, loading tiles of aerial imagery with roads and names superimposed.
Can someone help me out? Help us live on Mars!
public void myClickHandler(View target) {
switch(target.getId()) {
/*case R.id.zoomin:
mapView.getController().zoomIn();
break;
case R.id.zoomout:
mapView.getController().zoomOut();
break;*/
case R.id.sat:
this.mapView.setSatellite(true);
break;
case R.id.street:
this.mapView.setStreetView(true);
break;
case R.id.traffic:
this.mapView.setTraffic(true);
break;
case R.id.normal:
this.mapView.setSatellite(false);
this.mapView.setStreetView(false);
this.mapView.setTraffic(false);
break;
default:
break;
}
// The following line should not be required but it is,
// at least up til Froyo.
this.mapView.postInvalidateDelayed(2000);
}
i believe you need setStreetView, even though it says it's deprecated it works ok for me
#Deprecated
public void setStreetView(boolean on)
Deprecated. Street view availability highlighting is no longer supported. This method operates as a no-op.
Control whether Street View availability (blue outlines) is shown on the map. This is incompatible with Traffic indicators, so they will be deactivated if necessary. Street View availability can be drawn over map tiles or over satellite tiles; however, they are optimized for map tiles.
I don't believe this can be accomplished, because when you are using google mapview, the images come from google themself for road map and sattelite map, unless they do an update for the API to show only sattelite images without road names.
I wanted to load a custom KML file on the map. I chose the simple way:
Intent mapIntent = new Intent(Intent.ACTION_VIEW, url);
And it works well, but obviously I can't control various features like custom icons for overlay items, or the popup "Loading myKml.kml..." that shows everytime I start it, etc.
First question:
Aren't there any parameters to setup when I start a Google Maps Intent, to tweak my map? I can't find anything on the documentation.
So I was thinking about using the Google Maps API for my app. Well, I've managed to load my KML file parsing it with a SAX parser and creating a custom overlay for my map.
It works, but there is a great problem:
The placemarks aren't loaded dynamically in relation to my position. They are loaded from the start to the end, and are shown on the map 100 at time.
So it was going to be harder than I thought, because I'll have to get my position from the GPS and calculate only the nearest points and draw them on the map.
Second question:
Does exist a built-in function to show only near-to-me placemarks on the map?
Thank you, guys.
2nd question. No. Have a look at LocationManager.addProximityAlert(double latitude, double longitude, float radius, long expiration, PendingIntent intent).