I have an android app that takes an array from a website
{“d”:[{“latitude”:-1.0,”longitude”:-1.0,”time”:”07:14 PM 01/18/2038″,”most_recent”:”1″,”user_id”:”4e3f2c6659f25a0f8400000b”},{“latitude”:-1.0,”longitude”:-1.0,”time”:”07:14 PM 01/18/2038″,”most_recent”:”0″,”user_id”:”4e3f2c6659f25a0f8400000b”},{“latitude”:-1.0,”longitude”:-1.0,”time”:”07:14 PM 01/18/2038″,”most_recent”:”0″,”user_id”:”4e3f2c6659f25a0f8400000b”},{“latitude”:34.0608,”longitude”:-118.454,”time”:”07:14 PM 01/18/2038″,”most_recent”:”1″,”user_id”:”4e3da65e59f25a3956000005″},{“latitude”:34.0608,”longitude”:-118.454,”time”:”07:14 PM 01/18/2038″,”most_recent”:”0″,”user_id”:”4e3da65e59f25a3956000005″},{“latitude”:34.0608,”longitude”:-118.454,”time”:”07:14 PM 01/18/2038″,”most_recent”:”0″,”user_id”:”4e3da65e59f25a3956000005″}]}
as you can see each item has a latitude and longitude component as well as an id.
How do I modify this program to show either a green pin R.drawable.greenpin or a blue pin R.drawable.bluepin for “user_id”:”4e3f2c6659f25a0f8400000b” or “user_id”:”4e3da65e59f25a3956000005″ for each of the items in the array ( should be three blue pins and three green pins at these locations)
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
super.draw(canvas,mapView,shadow);
Point screenPts=new Point();
mapView.getProjection().toPixels(p,screenPts);
Bitmap bmp=BitmapFactory.decodeResource(getResources(),R.drawable.greenpin);
canvas.drawBitmap(bmp,screenPts.x,screenPts.y-50,null);
return true;
}
}
//to add the location marker
MapOverlay mapOverlay=new MapOverlay();
List<Overlay> listOfOVerlays=mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
The method that I have confuses me a bit because it draws the point based on the screen point. I would rather add these points by inserting the pins by the longitude and latitude of the arrays.
I don’t understanding what u want but in my case this code work for me, for put marker in appropriate lat,long address.
Thnx.