Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>``You need to use a class extending overlay classes ,for example(do note,this code is for fetching json not xml)</p> <pre><code>public class LocationOverlay extends ItemizedOverlay&lt;OverlayItem&gt; { private ArrayList&lt;OverlayItem&gt; overlayItemList = new ArrayList&lt;OverlayItem&gt;(); Context context; public LocationOverlay(Drawable marker, Context c) { super(boundCenterBottom(marker)); // TODO Auto-generated constructor stub populate(); context = c; } @Override protected boolean onTap(int index) { Toast.makeText(context, "Touch on marker: \n" + overlayItemList.get(index).getTitle(), Toast.LENGTH_LONG).show(); // code for passing storeid's OverlayItem item = overlayItemList.get(index); String idex = (item.getTitle()); Intent idtent = new Intent(context, StoreDetails.class); idtent.putExtra("&amp;", idex); context.startActivity(idtent); return true; } public void addItem(GeoPoint p, String title) { OverlayItem newItem = new OverlayItem(p, title, null); overlayItemList.add(newItem); populate(); } @Override protected OverlayItem createItem(int i) { // TODO Auto-generated method stub return overlayItemList.get(i); } @Override public int size() { // TODO Auto-generated method stub return overlayItemList.size(); } </code></pre> <p>now simply in the class where you are displaying the map ,do this</p> <pre><code>Double jlat = j4.getDouble("Latitude"); Double jlon = j4.getDouble("Longitude"); Log.v("Latitude", jlat + "n"); Log.v("Longitude", jlon + "n"); // Get the distance between lat long Location locationA = new Location("point A"); locationA.setLatitude(slat); locationA.setLongitude(slon); Location locationB = new Location("point B"); locationB.setLatitude(jlat); locationB.setLongitude(jlon); distance = (int) locationA.distanceTo(locationB); String str = " (" + String.valueOf(distance) + " meters)"; Log.v("Distance", str); // adjust drawable params Drawable marker = getResources().getDrawable( android.R.drawable.star_big_on); Drawable user = getResources().getDrawable( android.R.drawable.arrow_down_float); int userWidth = user.getIntrinsicWidth(); int userHeight = user.getIntrinsicHeight(); user.setBounds(0, userHeight, userWidth, 0); int markerWidth = marker.getIntrinsicWidth(); int markerHeight = marker.getIntrinsicHeight(); marker.setBounds(0, markerHeight, markerWidth, 0); // refernc to overlay class LocationOverlay myItemizedOverlay = new LocationOverlay( marker, MapActivity.this); LocationOverlay myItemizedOverlay1 = new LocationOverlay( user, MapActivity.this); mapView.getOverlays().add(myItemizedOverlay); mapView.getOverlays().add(myItemizedOverlay1); // create geopoint for user GeoPoint usr = new GeoPoint((int) (slat * 1e6), (int) (slon * 1e6)); // add overlay(user) to user's location myItemizedOverlay1.addItem(usr, "User"); mc.animateTo(usr); </code></pre> <p>and in the class above you can add any sort of handler whenever the user taps a geopoint..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload