Geo Coder并没有退回LatLng

时间:2014-10-18 20:28:30

标签: android google-maps map google-maps-android-api-2

我正在使用API​​ Maps v2 for Android构建应用程序..

我试图进行地理编码但没有成功..

我想传递地址并获得纬度和经度。我已经构建了以下代码,但这个代码下降到了Catch ..

   Geocoder gc = new Geocoder(MainActivity.this);

        List<Address> end;

        try{
            end = gc.getFromLocationName("Avenida Paulista, São Paulo, São Paulo, Brasil", 1);
            LatLng ll = new LatLng(end.get(0).getLatitude(), end.get(0).getLongitude());
            Toast.makeText(getApplicationContext(), "LatLng: "+ll, Toast.LENGTH_LONG).show();

        }catch(IOException e){
            e.printStackTrace();
            Toast.makeText(getApplicationContext(), "Coordenadas NÃO obtidas", Toast.LENGTH_LONG).show();
        }

此代码适用于地图V2?我太累了。拜托,有人可以帮助我吗? :)

logcat的:

10-18 17:53:18.824: I/SurfaceTextureClient(26928): [STC::queueBuffer] this:0x517528b0, api:1,  last queue time elapsed :90190 ms
10-18 17:53:18.824: I/SurfaceTextureClient(26928): [0x517528b0] frames:5, duration:90.353996, fps:0.055338
10-18 17:53:18.913: W/ActionMenuPresenter(26928): showOverflowMenu fail, mReserveOverflow=true, mMenu.getNonActionItems().size()=4, isOverflowMenuShowing()=false
10-18 17:53:18.928: D/AbsListView(26928): checkAbsListViewlLogProperty get invalid command
10-18 17:53:18.971: W/MMUMapper(26928): fail to register MVA, unsupported format(0x5)
10-18 17:53:19.026: W/MMUMapper(26928): fail to register MVA, unsupported format(0x5)
10-18 17:53:19.103: W/MMUMapper(26928): fail to register MVA, unsupported format(0x5)
10-18 17:53:19.913: W/System.err(26928): java.io.IOException: Service not Available
10-18 17:53:19.914: W/System.err(26928):    at android.location.Geocoder.getFromLocationName(Geocoder.java:181)
10-18 17:53:19.915: W/System.err(26928):    at com.example.googlemaps.MainActivity.onOptionsItemSelected(MainActivity.java:167)
10-18 17:53:19.915: W/System.err(26928):    at android.app.Activity.onMenuItemSelected(Activity.java:2546)
10-18 17:53:19.916: W/System.err(26928):    at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:971)
10-18 17:53:19.917: W/System.err(26928):    at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
10-18 17:53:19.917: W/System.err(26928):    at     com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
10-18 17:53:19.918: W/System.err(26928):    at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
10-18 17:53:19.918: W/System.err(26928):    at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:175)
10-18 17:53:19.920: W/System.err(26928):    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
10-18 17:53:19.920: W/System.err(26928):    at android.widget.AbsListView.performItemClick(AbsListView.java:1118)
10-18 17:53:19.921: W/System.err(26928):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3058)
10-18 17:53:19.923: W/System.err(26928):    at android.widget.AbsListView.onTouchEvent(AbsListView.java:3828)
10-18 17:53:19.923: W/System.err(26928):    at android.view.View.dispatchTouchEvent(View.java:7146)
10-18 17:53:19.924: W/System.err(26928):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2238)
10-18 17:53:19.924: W/System.err(26928):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1935)
10-18 17:53:19.924: W/System.err(26928):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
10-18 17:53:19.925: W/System.err(26928):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
10-18 17:53:19.925: W/System.err(26928):    at android.widget.PopupWindow$PopupViewContainer.dispatchTouchEvent(PopupWindow.java:1576)
10-18 17:53:19.925: W/System.err(26928):    at android.view.View.dispatchPointerEvent(View.java:7332)
10-18 17:53:19.927: W/System.err(26928):    at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3520)
10-18 17:53:19.927: W/System.err(26928):    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3454)
10-18 17:53:19.928: W/System.err(26928):    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4543)
10-18 17:53:19.929: W/System.err(26928):    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4522)
10-18 17:53:19.930: W/System.err(26928):    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4618)
10-18 17:53:19.930: W/System.err(26928):    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
10-18 17:53:19.931: W/System.err(26928):    at android.os.MessageQueue.nativePollOnce(Native Method)
10-18 17:53:19.932: W/System.err(26928):    at android.os.MessageQueue.next(MessageQueue.java:125)
10-18 17:53:19.933: W/System.err(26928):    at android.os.Looper.loop(Looper.java:140)
10-18 17:53:19.934: W/System.err(26928):    at android.app.ActivityThread.main(ActivityThread.java:4987)
10-18 17:53:19.934: W/System.err(26928):    at java.lang.reflect.Method.invokeNative(Native Method)
10-18 17:53:19.935: W/System.err(26928):    at java.lang.reflect.Method.invoke(Method.java:511)
10-18 17:53:19.935: W/System.err(26928):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
10-18 17:53:19.936: W/System.err(26928):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
10-18 17:53:19.936: W/System.err(26928):    at dalvik.system.NativeStart.main(Native Method)
10-18 17:53:19.945: D/OpenGLRenderer(26928): Flushing caches (mode 0)
10-18 17:53:19.965: W/MMUMapper(26928): invalid operation for unregister MVA with VA(0x5513d000) size(189056) f(0x5)
10-18 17:53:19.966: W/MMUMapper(26928): invalid operation for unregister MVA with VA(0x5516c000) size(189056) f(0x5)
10-18 17:53:19.966: W/MMUMapper(26928): invalid operation for unregister MVA with VA(0x551ec000) size(189056) f(0x5)
10-18 17:53:19.973: W/InputEventReceiver(26928): Attempted to finish an input event but the input event receiver has already been disposed.
10-18 17:53:20.011: W/MMUMapper(26928): fail to register MVA, unsupported format(0x1)
10-18 17:53:20.015: I/SurfaceTextureClient(26928): [STC::queueBuffer] this:0x51731c78, api:1, last queue time elapsed :91392 ms
10-18 17:53:20.015: I/SurfaceTextureClient(26928): [0x51731c78] frames:4, duration:91.500000, fps:0.043716
10-18 17:53:20.028: I/BufferQueue(26928): [BQ::queueBuffer] unnamed-26928-0(0x51741980), api=1, queued=1 (drop frame)
10-18 17:53:20.043: I/SurfaceTextureClient(26928): [0x517528b0] frames:2, duration:1.218000, fps:1.641839
10-18 17:53:23.443: W/MMUMapper(26928): invalid operation for unregister MVA with VA(0x54c9f000) size(45696) f(0x1)    

0 个答案:

没有答案