|
|
|
Android ถามเรื่องการค้นหาสถานที่มาใช้ในการหา Search ต่ำแหน่งบน Google map ครับ |
|
|
|
|
|
|
|
ลองดูครับ
Code (Android-Java)
class MapOverlay extends com.google.android.maps.Overlay
{
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
//---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);
//---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), R.drawable.pink);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-32, null);
return true;
}
}
Code (Android-Java)
List<Address> addresses = geoCoder.getFromLocationName(txtsearch.getText().toString(),5);
if(addresses.size() > 0)
{
p = new GeoPoint( (int) (addresses.get(0).getLatitude() * 1E6),
(int) (addresses.get(0).getLongitude() * 1E6));
controller.animateTo(p);
controller.setZoom(12);
MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = map.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
map.invalidate();
txtsearch.setText("");
}
else
{
AlertDialog.Builder adb = new AlertDialog.Builder(GoogleMap.this);
adb.setTitle("Google Map");
adb.setMessage("Please Provide the Proper Place");
adb.setPositiveButton("Close",null);
adb.show();
}
http://stackoverflow.com/questions/5375654/how-to-implement-google-maps-search-by-address-in-android
|
|
|
|
|
Date :
2012-12-11 09:04:09 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|