Android系列只androidGooglemap小应用
2010-08-19 14:32:00 来源:WEB开发网核心提示:selectedMapLocation != null; 69 } 70 71 @Override 72 public void draw(Canvas canvas, MapView mapView, boolean shadow) { 73 74 drawMapLocations(canvas, mapView,
selectedMapLocation != null; 69 } 70 71 @Override 72 public void draw(Canvas
canvas, MapView mapView, boolean shadow) { 73 74 drawMapLocations(canvas,
mapView, shadow); 75 //drawInfoWindow(canvas, mapView, shadow); 76 } 77 78
private RecordLocation getHitMapLocation(MapView mapView, GeoPoint tapPoint) {
79 80 // Track which MapLocation was hit...if any 81 RecordLocation
hitMapLocation = null; 82 83 RectF hitTestRecr = new RectF(); 84 Point
screenCoords = new Point(); 85 Iterator iterator =
mapLocationViewer.getMapLocations().iterator(); 86 while(iterator.hasNext()) {
87 RecordLocation testLocation = iterator.next(); 88 89 // Translate the
MapLocation's lat/long coordinates to screen coordinates 90
mapView.getProjection().toPixels(testLocation.getPoint(), screenCoords); 91 92
// Create a 'hit' testing Rectangle w/size and coordinates of our icon 93 // Set
the 'hit' testing Rectangle with the size and coordinates of our on screen icon
94
hitTestRecr.set(-bubbleIcon.getWidth()*2,-bubbleIcon.getHeight()*2,bubbleIcon.getWidth()*2,0);
95 hitTestRecr.offset(screenCoords.x,screenCoords.y); 96 97 // Finally test for
a match between our 'hit' Rectangle and the location clicked by the user 98
mapView.getProjection().toPixels(tapPoint, screenCoords); 99 if
(hitTestRecr.contains(screenCoords.x,screenCoords.y)) {100 hitMapLocation =
testLocation;101 break;102 }103 }104 105 // Lastly clear the newMouseSelection
as it has now been processed106 tapPoint = null;107 108 return
hitMapLocation;109 }110 111 private static final int
VOLUME=1,VIBRATE=2,VOLUMEOFF=3,VOLUMEVIBRATE=4;112 private void
drawMapLocations(Canvas canvas, MapView mapView, boolean shadow) {113 114
if(mapLocationViewer.getMapLocations()!=null){115 116 Iterator
iterator = mapLocationViewer.getMapLocations().iterator();117 Point screenCoords
= new Point();118 while(iterator.hasNext()) {119 RecordLocation location =
iterator.next();120 mapView.getProjection().toPixels(location.getPoint(),
Tags:Android 系列 androidGooglemap
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接