How do I launch Maps intent with label and sub-label? - android

I have an intent picker in my app. When the user selects Google Maps, I want to set the title and subtitle in the maps.
How do I get the subtext set in Google Maps?
I looked at the api(https://developer.android.com/guide/components/intents-common.html#Maps) and I used
geo:0,0?q=lat,lng(label)
But I can only set the title text(label) using this. How do I set the subtitle?
I want to do it only using common intent for location and not just Google Maps.

Related

Google Places API AutcompleteSupportFragment not requesting focus

I am using the autocomplete support fragment from the Google Places API and am facing a small issue. When I click on the search button (Shown in 1).
I am able to see image 2. But what I want to see is image [3]. I want the keyboard to be up as soon as I click on the search button but instead, I need to make 2 clicks to get the keyboard.
From the looks of the pictures, it seems you're using overlay place picker not full display.
Then your code should be like this using an Autocomplete.IntentBuilder to create an intent to launch the autocomplete widget as an intent:
int AUTOCOMPLETE_REQUEST_CODE = 1;
List<Place.Field> fields = Arrays.asList(Place.Field.ID,
Place.Field.NAME);
// Start the autocomplete intent.
Intent intent = new Autocomplete.IntentBuilder(
AutocompleteActivityMode.FULLSCREEN, fields)
.build(this);
startActivityForResult(intent,
AUTOCOMPLETE_REQUEST_CODE);
You can either replace the FULLSCREEN with OVERLAY depending on your choice.

How to hide Google logo from google maps by adding Overlaid image on google maps?

I am adding Bitmap image on Google maps using GroundOverlayOptions, that image will be overlaid on the Google maps.
Below is my code.
#Override
public void onLocationChanged(Location location) {
TextView tvLocation = (TextView) findViewById(R.id.tv_location);
location = generateRandomLoc(location, 0);
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude, longitude);
//Setting padding to hide google logo
mapView.setPadding(-10,0,0,0);
CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng).build();
mapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
mapView.moveCamera(CameraUpdateFactory.newLatLng(latLng));
//get camera position frm map view
LatLng cameraPosLatLng = mapView.getCameraPosition().target;
if (isFlag) {
BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.overlay_pink_image);
mapView.addGroundOverlay(new GroundOverlayOptions()
.image(image).position(latLng, 458, 274)
.transparency(0.5f));
mapView.animateCamera(CameraUpdateFactory.zoomTo(17));
}
if (cirle != null) {
cirle.remove();
}
cirle = mapView.addCircle(new CircleOptions().center(cameraPosLatLng).strokeColor(Color.GREEN).fillColor(Color.GREEN).radius(0.7));
}
I am trying to hide Google logo from the MapView by setting padding, but That logo won't be hidden from the MapView. When I set -10 padding at left or bottom that 10% of view will be disabled. But in case of map view, this may be different. If I set padding(50,0,0,0); that logo will be placed at right. How can I disable or hide the logo of Google on Google maps.
Any help would be appreciated.
Try to respect the Google Maps Terms of Service
9.4 Attribution.
Content provided to you through the Service may contain the Brand Features of Google, its strategic partners, or other third-party rights holders of content that Google indexes. When Google provides those Brand Features or other attribution through the Service, you must display such attribution as provided (or as described in the Maps APIs Documentation) and must not delete or alter the attribution.
You must conspicuously display the "powered by Google" attribution (and any other attribution(s) required by Google in the Maps APIs Documentation) on or adjacent to the relevant Service search box and Google search results. If you use the standard Google search control, or the standard Google search control form, this attribution will be included automatically, and you must not modify or obscure this automatically-generated attribution.
Developers don't have the authority to replace the logo even though it's possible.
[UPDATE]
3.2.3 Requirements for Using the Services.
(b) Attribution. Customer will display all attribution that (i) Google provides through the Services (including branding, logos, and copyright and trademark notices); or (ii) is specified in the Maps Service Specific Terms. Customer will not modify, obscure, or delete such attribution.
Simple! I achieved this by doing the following either directly on the fragment or any parent layout.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="-30dp"
android:layout_marginTop="-30dp">
<fragment
android:id="#+id/map_frag_main"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" />
</RelativeLayout>
Adding the layout_margin will clip away the Google logo and no need for padding, just make sure you add a drawable or you will be violating TOS. Cheers!
Hiding Google logo from Google map and Google earth images are against terms of usage of Google Maps. So even though there might be a way to do it, it would be illegal. You can found TOS and related rule below.
https://developers.google.com/maps/terms
9.4 Attribution.
Content provided to you through the Service may contain the Brand Features of Google, its strategic partners, or other third-party rights holders of content that Google indexes. When Google provides those Brand Features or other attribution through the Service, you must display such attribution as provided (or as described in the Maps APIs Documentation) and must not delete or alter the attribution.
You can achieve it in Android using:
final ViewGroup googleLogo = (ViewGroup) findViewById(R.id.single_map).findViewWithTag(Const.GOOGLE_MAPS_WATERMARK).getParent();
googleLogo.setVisibility(View.GONE);
Where single_map is the instance of SupportMapFragment.
You may remove it through xml or programatically but simple official answer to it is.
You can’t, because it is not legal
This CSS will remove Google Logo, terms of use, and Report a problem div.
a[href^="http://maps.google.com/maps"]{display:none !important}
a[href^="https://maps.google.com/maps"]{display:none !important}
.gmnoprint a, .gmnoprint span, .gm-style-cc {
display:none;
}
.gmnoprint div {
background:none !important;
}

How to handle the click event on current location icon on google maps in android

I am getting an icon shown in the figure on the google Maps. Now i have the confusion how to show the current location on the maps with marker whenever a user clicks on the current Location icon the google maps.
After placing this code i got the icon on the google maps
Map.setMyLocationEnabled(true);
On the top-right google map is showing the current location icon, Now my confusion is how to handle this event to show my current location on the google maps.
use setOnMyLocationButtonClickListener() and override
#Override
public boolean onMyLocationButtonClick(){
return false;
}
returning false does the default behavior

Google maps V2 marker's title in other languages

I want to show a marker on Google Maps API V2:
this is my code:
driverMarker = new MarkerOptions();
driverMarker.icon(BitmapDescriptorFactory.fromResource(R.drawable.driver_car));
driverMarker.position(driverLocation);
driverMarker.title(getDriver().getName());
googleMap.addMarker(driverMarker);
The driver name is saved in Hebrew, and also my Google maps language is in Hebrew (the street names). However, when my getDriver().getName() returns string in Hebrew it doesn't show me the title (the title is blank as you can see in the screenshot attached). But if the poi.getName() returns string in english it show the title on the marker...
What can I do in order to display Hebrew on the marker's title???
screenshot
You can find the solution here by #Gavriel:
Non-ASCII title for android map marker
In short:
You can use android:textDirection="locale" on TextView in customized InfoWindowAdapter (if you are using api 17 and higher)
or
Prepend an unicode left-to-right mark to the title/snippet:
.title("\u200e" + titleText)
.snippet("\u200e" + snippetText)

How to customize root in android google map navigation?

I am implementing Google navigation by opening the URL -
https://maps.google.co.in/maps?saddr=xxxxxxxxxxxxxxxxxx&daddr=xxxxxxxxxxxxx
where xxxx means source address and destination address.
It will show the options for different routes or show the default route.
I have to set a new route from option at first and after that instead of default route, i want to show the route i selected first in my app...
please help me ..
thanks in advance

Categories

Resources