Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- google maps: dynamic canvas drawing in mapview
- ((Button)findViewById(R.id.goMap)).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- mapView.invalidate();
- // On récupère notre EditText
- EditText UserName = ((EditText)findViewById(R.id.getLon));
- EditText Password = ((EditText)findViewById(R.id.getLat));
- // On garde la chaîne de caractères
- _lat = UserName.getText().toString();
- _long = Password.getText().toString();
- latTest = Double.parseDouble(_lat)* 1E6;
- longTest = Double.parseDouble(_long)* 1E6;
- p3 = new GeoPoint(
- (int) (latTest ),
- (int) (longTest ));
- //---add the marker---
- Bitmap bmp3 = BitmapFactory.decodeResource(
- getResources(), R.drawable.maps_position_marker);
- Canvas canvas= new Canvas();
- canvas.drawBitmap(bmp3, screenP3ts.x-15, screenP3ts.y-30, null);
- mapView.getProjection().toPixels(p3, screenP3ts);
- mapController.animateTo(p3);
- mapController.setCenter(p3);
- Toast.makeText(TheMap.this, "lat=" + latTest + " et " + "long= " + longTest, Toast.LENGTH_SHORT).show();
- }
- });
- Bitmap bmp3 = BitmapFactory.decodeResource(
- getResources(), R.drawable.maps_position_marker);
- Canvas canvas= new Canvas();
- mapView.getProjection().toPixels(p3, screenP3ts);
- canvas.drawBitmap(bmp3, screenP3ts.x-15, screenP3ts.y-30, null);
Add Comment
Please, Sign In to add comment