Default current location pin in Skobbler map - android

I am using skobbler map for Android. I do not require current location to pointed on the map, so I am not registering for the current location listener and skobbler map itself adds an default current location pin on the map. Please check the image attached. , please tell me how to not display this. And, by default the maps takes to Berlin, Germany can this be avoided? If yes, how?

You can set the behavior of the default position annotation with mapView.getMapSettings().setCurrentPositionShown(false).
To center the map on a desired location use mapView.centerMapOnPosition(skPosition).
Where mapView is your SKMapSurfaceView instance.

Please check the below code hope its help you.As its working at my end.
#Override
public void onCurrentPositionUpdate(SKPosition skPosition) {
this.currentPosition = skPosition;
SKPositionerManager.getInstance().reportNewGPSPosition(this.currentPosition);
mapView.animateToLocation(skPosition.getCoordinate(), 7);
mapView.animateToZoomLevel(7);
}

You can try to call in onSurfaceCreated:
SKCoordinate coord = new SKCoordinate(-37.585162f, 40.418143f);
mapView.setPositionAsCurrent(coord, 0, true);
mapView.setZoom(4);

Related

Does Google Maps Android API locate me automatically?

I am working with Google Maps Android API V2.
When my map fragment is loaded it shows my location automatically (with the blue dot). Why does this happen? Is my location history affecting or is the default working mode?
Does this code cause it?:
googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
#Override
public void onMyLocationChange(Location location) {
googleMap.setOnMyLocationChangeListener(null);
}
});
I have commented this piece of code but the map is still showing the blue dot.
If this is not happening because of the history, would this piece of code be enough to get user location or do I need to use LocationManager class as described in other questions?
Try to use
googleMap.setMyLocationEnabled(true/false);
to control showing your location on map. I think it is enough to turn the setting on to make your location work with Google Maps, without need to use LocationManager etc.

Listener for new Button to get my location in GMaps v2

I think that it is a really noob question but i could not do it.
In new Google maps API for Android (v2) you can get you location right now touching the new button that appears on the map when you code:
myMap.setMyLocationEnabled(true);
That's works fine but I want to "catch" the event when the user touch this button because i want to add more actions and I don't know how to reference that button in code.
Anyone knows?
Thanks in advance.
GoogleMap.OnMyLocationButtonClickListener was just announced. probably going to be released today in the next Google APIs version.
This is not currently possible via the api.
A feature request is already pending and I think this will be added soon.
See this: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4789
Oh yes, sorry. I should have read your question more clearly.
In order to your question:
In those situations, I recommened that you layout out your own my-location-button on the mapView and add a clicklistener on that and over location-listener, you can get the current position.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), zoom));

Google Maps API v2 invoke behaviour of clicking mylocationbutton

I have a fully working GoogleMap and I can show my userlocation with the call
mMap.setMyLocationEnabled(true);
What I want to accomplish is the functionality of the actual click on the button that now appears on the GoogleMap (I.e animating the map to the userlocation with correct zoom etc).
The functionality is there in the GoogleMap-object already, how do I use it?
I do not want to use a LocationListener or such to accomplish this, I just want to "call the same code" that gets called when I click the button on the map. Can it be that simple?
Thanks in advance.
EDIT:
What I basically want to do is to center the map at the user location, exactly the way that the GoogleMap centers at user location when I click the button. Like this:
GoogleMap mMap = this.getMap();
if(mMap != null) {
mMap.setMyLocationEnabled(true);
//TODO center the map on mylocation
}
EDIT:
Apparently Google is working on this. http://code.google.com/p/gmaps-api-issues/issues/detail?id=4644
This is how I do to navigate to the center of the map when we get the first location-update.
my class header:
public class FragActivity extends SherlockFragmentActivity implements OnMyLocationChangeListener
private GoogleMap mMap;
my mMap-setup:
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = customMapFragment.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null)
setUpMap();
}
setUpMap-method:
private void setUpMap() {
mMap.setMyLocationEnabled(true);
mMap.setOnMyLocationChangeListener(this);
}
and my onlocationchange:
#Override
public void onMyLocationChange(Location lastKnownLocation) {
CameraUpdate myLoc = CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder().target(new LatLng(lastKnownLocation.getLatitude(),
lastKnownLocation.getLongitude())).zoom(6).build());
mMap.moveCamera(myLoc);
mMap.setOnMyLocationChangeListener(null);
}
Works like a charm
Not really sure why the other answers are talking about OnMyLocationChangeListeners. This is not what was asked in the OP. What was asked was how to replicate the exact behavior of clicking on the MyLocationButton, which is actually more complex than just animating the camera to the user's location. The button does different things depending on what zoom level you're currently on.
For example, when you're zoomed way out, clicking the button will animate you to your location while zooming you in, whereas if you're already at certain zoom levels, clicking the button will only animate you to your location while maintaining the current zoom level.
Rather than painstakingly trying to replicate this behavior, wouldn't it be great if we could simply get a reference to the MyLocationButton and just, you know, click it? Well, this is the current best way I've found to do just that:
#OnClick(R.id.fabMyLocation)
public void onMyLocationClick(FloatingActionButton fabMyLocation) {
View myLocationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent())
.findViewById(Integer.parseInt("2"));
myLocationButton.performClick();
}
Yeah, it's not pretty, and relies on hardcoded IDs that may change in future versions of the Google Maps API. But this method of retrieving the button is based off of this highly rated answer from 2013 and so far, as of Google Play Services 8.4.0, still works flawlessly.
Update February 2013:
This is now possible. You can now set the map's OnMyLocationChangeListener. Receive an update as you want and move the camera accordingly.
This is not possible. I've found that the GoogleMap in Android is quite limited in the information that it gives you. It simply doesn't give you direct access to the user location updates or to the button that the user can press (you can only enable/disable it, not simulate a press).
You must implement the LocationSource and LocationListener interfaces and use a LocationManager to get updates from the device and use them to send them to the map.
You could then add your own custom button to the overlay to replicate the default button and use your own camera and zoom controls to simulate the functionality.
Source: hours of searching

Show Taiwan Map in Android Application

Here I develop one application which shows Map in Application. I show map in my app and it is working fine, but I show that country which I want to display in Map from application. So how to do it? Is it possible in Android?
Please help me.
Thanks in Advance.
First of all track you current position through LocationListener/LocationManager:
MyLocation myLocation = new MyLocation();
private void locationClick() {
myLocation.getLocation(this, locationResult);
}
And, zoom out your location through code:
mapView.getController().setZoom(17);
Then you can see the country mentioned.

How to integrate current locatioon in android project mapview balloons

I'm trying out the info balloon from: https://github.com/jgilfelt/android-mapviewballoons and it's working perfectly. One thing I'm missing is the ability of setting the current location. Does anybody know how to precisely implement that function?
Thanks in advance !
Yes, for example I have some url variable which I display in baloon and my onBaloonTap looks like this, where c is context
#Override
protected boolean onBalloonTap(int index, OverlayItem item) {
String url = WebService.upcomigEvent;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
c.startActivity(i);
return true;
}
You can track position by implementing the LocationListener interface, or by using the MyLocationOverlay class. In both, the method onLocationChanged is available, and you can provide it with your own location object that you create, specifying the lat/lng/alt. This in effect 'spoofs' the users location, and this might not be what you want. If you just want to scroll the map to a specific point you can use the animateTo method available in the MapController.

Categories

Resources