How to Draw Route Received From MapQuestApi in nutiteq Map? - android

i have some problems creating route directionns on the nutiteq map from MapQuestApi, i Know how to Receive the Information needed
#Override
public void onSuccess(RouteResponse routeResponse) {
clearButton.setVisibility(View.VISIBLE);
if(showItineraryButton.getVisibility()==View.GONE &&
showMapButton.getVisibility()==View.GONE){
showItineraryButton.setVisibility(View.VISIBLE);
}
createRouteButton.setEnabled(true);
}
});
but i dont know how to use them to create route lines on them nutiteq map, and appearantly its demo sample doesnt say any thing, it has a RouteActivity Interface which does not exists any where in the Sample Codes, if any one has done this , can some one please show me how can i "draw" the route points using received information ? i would really appreciate

The RouteActivity is in separate project AdvancedLayers.
From MapQuestRouteActivity.java in AdvancedMap3D project you can find method public void routeResult(Route route) which is called from MapQuestDirections.java (source is also in AdvancedLayers). The MapQuestDirections has already parsed routing result and created a line (which is part of the Route) which can be added to the map.

Related

How can I make the circles clickable on MapBox?

I am working with Mapbox to create a map application. I want to have some clickable circles on the map. I already got the circles on the map but i cant seem to make them clickable. I read about a circlemanager that I need to use but I cant get that to work.
I've already tried to make a Circlemanager as seen below.
CircleManager circleManager = new CircleManager(mapView, mapboxMap, style);
circleManager.addClickListener(circle -> Toast.makeText(container.getContext(),
String.format("Circle clicked %s", circle.getId()),
Toast.LENGTH_LONG).show());
I wrote that code so I can test if the application detects the click. But I don't get any feedback/errors.
You can have a look from GitHub repository might it work for you.
https://github.com/mapbox/mapbox-plugins-android/blob/master/app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/CircleActivity.java

android-how can i get exact number while implement cluster manager in google map in "Android" please give me proper answer if anyone have...?

How Can I get exact number in bucket of cluster manager?
Can anyone give me an example ? how to get exact like 42,35 instead of 20+,50+ etc ?
May be this is not the best answer but it has been work for me.
public class CustomClusterClass extends DefaultClusterRenderer<Data> {
public CustomClusterClass(Context context, MapboxMap map,
ClusterManagerPlugin<Data> clusterManagerPlugin) {
super(context, map, clusterManagerPlugin);
}
#Override
protected String getClusterText(int bucket) {
return super.getClusterText(bucket).replace("+", "");
}
#Override
protected int getBucket(Cluster<Data> cluster) {
return cluster.getSize();
}
}
If you check the documentation of clustering in Google Maps Android API, you will see here on how to customize the marker cluster.
It is stated here that the ClusterManager constructor creates a DefaultClusterRenderer and you can change the ClusterRenderer and the Algorithm using the setAlgorithm(Algorithm<T> algorithm) and setRenderer(ClusterRenderer<T> view) methods of ClusterManager.
The DefaultClusterRenderer provides a base to start from, and to override this defaults, you need to subclass the DefaultClusterRenderer.
For more information, you can check this thread and this sample code on how to customize the marker cluster.
You have to customize DefaultClusterRenderer class.
//to get the exact count of map clustering
protected int getBucket(Cluster<T> cluster) {
int size = cluster.getSize();
return size;
}
refer this link https://github.com/MadhuProjectWorks/GoogleMapClustering
For anyone else visiting later:
As far as my experience with Android is concerned, you will need to use a custom cluster if you want to display the exact number of items in a cluster. I too have been searching for a way to show the exact number while using the default cluster marker / circle.
So, just as everyone is pointing out, check out the sample code here. You will then need to use the below code to get the exact cluster item count:
override fun onBeforeClusterRendered(cluster: Cluster<MyClusterItem>?, markerOptions: MarkerOptions?){
//... create your view
val clusterSize = cluster?.items?.size
//user clusterSize on your custom view
}
Once again, be patient and go through the code in the link and create your own view and eventually you will be using the cluster size and you want it to be.

How to detect a longpress guesture with Google Map V2?

I am an android fresh man and developing a small app with Google Map V2.
I want to get the WGS84 (i.e. LatLng)position when longpress on the MAP.
Several methods are tried as the answers in other topic but the longpress guesture still could not be detected.
Can anyone help on this to provide some sample code for me?
Have you tried this?
mMap.setOnMapLongClickListener(new OnMapLongClickListener() {
#Override
public void onMapLongClick(final LatLng point) {
}
});

Xamarin Android Google Map v2 SetOnCameraChangeListener Method

I am working on android map app in xamarin android. I want to handle the zoom event of map. Can anybody tell me how can I do this in xamarin android using map.SetOnCameraChangeListener ..
Regards
This is a bit late of an answer, but this really helped me. Should have everything you need.
http://pastebin.com/dgdiDk2N
Basically you need to implement the interface:
public class MapTab : Fragment, GoogleMap.IOnCameraChangeListener
Then you can set the listener as such:
map.SetOnCameraChangeListener (this);
And you will also need to add the method OnCameraChange:
public async void OnCameraChange (CameraPosition cameraPos)
{
//Do your things here when the camera updates
}

Adding a custom OnMarkerDragListener makes markers no longer draggable

I'm using Google Maps v2 in an Android application that I'm writing. After creating the map and adding all the markers to it, I make all the markers draggable by using marker.setDraggable(true); for each marker on the map.
If I run the code like this, the markers are indeed draggable. However, I'd like to change the icon or color of the marker while it's being dragged, so I set up an OnMarkerDragListener, like so:
map.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
#Override
public void onMarkerDragStart(Marker marker) {
marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
}
#Override
public void onMarkerDrag(Marker marker) {
}
#Override
public void onMarkerDragEnd(Marker marker) {
marker.setIcon(BitmapDescriptorFactory.defaultMarker());
}
});
After adding in that block of code, though, the markers are no longer draggable. The color successfully changes in both the onMarkerDragStart and onMarkerDragEnd methods, but that's it. Can anyone explain what I'm doing wrong here, and why the markers aren't getting dragged ?
i would say that the problem comes from changing the icon rather than from settings the listener.
Please note that Marker.setIcon is not a function that is available in all the versions of the GoogleMaps V2 API. This means that probably it is not available in the library you have, or in the version of the play services installed in the device in which you are trying your app, and that could be causing any kind of malfunction.
As you can read here that function was added in May 2013. Please try updating everything, the google-play-services_lib, and the play services installed in the device.
If this happen to fix it, then you can try to change the icon only depending on the version installed on the mobile.

Categories

Resources