Guest User

Untitled

a guest
Aug 3rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. google maps: dynamic canvas drawing in mapview
  2. ((Button)findViewById(R.id.goMap)).setOnClickListener(
  3. new OnClickListener() {
  4. @Override
  5. public void onClick(View v) {
  6.  
  7.  
  8.  
  9. mapView.invalidate();
  10. // On récupère notre EditText
  11. EditText UserName = ((EditText)findViewById(R.id.getLon));
  12. EditText Password = ((EditText)findViewById(R.id.getLat));
  13.  
  14. // On garde la chaîne de caractères
  15. _lat = UserName.getText().toString();
  16. _long = Password.getText().toString();
  17.  
  18. latTest = Double.parseDouble(_lat)* 1E6;
  19. longTest = Double.parseDouble(_long)* 1E6;
  20.  
  21. p3 = new GeoPoint(
  22. (int) (latTest ),
  23. (int) (longTest ));
  24.  
  25. //---add the marker---
  26. Bitmap bmp3 = BitmapFactory.decodeResource(
  27. getResources(), R.drawable.maps_position_marker);
  28. Canvas canvas= new Canvas();
  29. canvas.drawBitmap(bmp3, screenP3ts.x-15, screenP3ts.y-30, null);
  30.  
  31.  
  32. mapView.getProjection().toPixels(p3, screenP3ts);
  33. mapController.animateTo(p3);
  34. mapController.setCenter(p3);
  35.  
  36. Toast.makeText(TheMap.this, "lat=" + latTest + " et " + "long= " + longTest, Toast.LENGTH_SHORT).show();
  37.  
  38.  
  39. }
  40. });
  41.  
  42. Bitmap bmp3 = BitmapFactory.decodeResource(
  43. getResources(), R.drawable.maps_position_marker);
  44. Canvas canvas= new Canvas();
  45.  
  46. mapView.getProjection().toPixels(p3, screenP3ts);
  47. canvas.drawBitmap(bmp3, screenP3ts.x-15, screenP3ts.y-30, null);
Add Comment
Please, Sign In to add comment