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...
Related
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.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Best Way to Add Map Pins to Google Map Android
How to add pin and if clicked show balon with info address or city which I have custom getOverlay() in google maps API android.
Below my code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_map);
mapView = (MapView) findViewById(R.id.map_view);
GeoPoint gpStart = new GeoPoint((int) (-6.31689 * 1E6),
(int) (106.74040 * 1E6));
GeoPoint gpEnd = new GeoPoint((int) (-6.29729 * 1E6),
(int) (106.78386 * 1E6));
Route r = direction(gpStart, gpEnd);
RouteOverlay rOverlay = new RouteOverlay(r, Color.RED);
mapView.getOverlays().add(rOverlay);
mapView.getController().animateTo(gpStart);
mapView.getController().setZoom(15);
mapView.setBuiltInZoomControls(true);
}
My code have edited, Code in above i get from here and work for me, but not show pin on location. I know to put pin wich if code is standart from google maps V1. Just add overlay. But my problem is I get map from json array. So i want to add pin in location(geopoint) and if i click i get info address.
Thanks.
If you're using the Google Maps Android API v2, which you should do, it's documented here.
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Hello world"));
I have a GPS map and want to use a custom geopoint (using a my PNG) that when I click on a place in the map returns latitude and longitude.
Searching I have found this code
public void recieveLongClick(MotionEvent ev)
{
Projection p = mapView.getProjection();
GeoPoint geoPoint = p.fromPixels((int) ev.getX(), (int) ev.getY());
// You can now pull lat/lng from geoPoint
}
But I don't know how to use this and how to define a GeoPointer with a custom image that is showed when someone click on a place in the map.
I can take my location with myLocationOverlay easily, and I want to set as a center of my location, I tried map controller:
MapController mc = myMap.getController();
mc.animateTo();
mc.setCenter(myLocOverlay.getMyLocation());
these code didnt work so I changed
p = new GeoPoint((int) (myLocOverlay.getMyLocation().getLatitudeE6()), (int) (myLocOverlay.getMyLocation().getLongitudeE6()));
mc.setCenter(p);
But there is no good news. I took null pointer exception then I assigned new location before myLocationOverlay() but its not working.. Thanks for advance..
The animateTo can be used for this,
GeoPoint point = this.currentLocationOverlay.getMyLocation();
if(point==null)
return;
//center map on that geopoint
mc.animateTo(point);
I want to point to a Google map location using overlay. For this purpose latitude and longitude values will be assigned to a GeoPoint, but it only accepts int values.
How can I assign it a double value? Or is there another solution to point to an exact location?
point = new GeoPoint((int)t.getLati(),(int)t.getLongi())
Any help would be appreciated.
Since GeoPoint accepts latitudes and longitudes in microdegrees, simply create your point like so:
GeoPoint point = new GeoPoint((int)(latitude * 1e6),
(int)(longitude * 1e6));