在arraylist中存储lat和lng

时间:2018-05-06 14:52:38

标签: android google-maps

我在地图上显示位置并显示标记只是问题是将所有附近位置lat lang存储在数组中

   private void showNearbyPlaces(List<HashMap<String, String>> nearbyPlaceList) {
            int size = nearbyPlaceList.size();
            arrayList = new ArrayList<LatLng>();
            for (int i = 0; i < size; i++) {
                MarkerOptions markerOptions = new MarkerOptions();
                HashMap<String, String> googlePlace = nearbyPlaceList.get(i);
                String placeName = googlePlace.get("place_name");
                String vicinity = googlePlace.get("vicinity");
                double lat = Double.parseDouble(googlePlace.get("lat"));
                double lng = Double.parseDouble(googlePlace.get("lng"));
                LatLng latLng = new LatLng(lat, lng);
                arrayList.add(latLng);
                markerOptions.position(latLng);
                markerOptions.title(placeName + " : " + vicinity);
                markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
                mMap.addMarker(markerOptions);
                Log.d("getnearbyplaces", "marker added");
                mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
                mMap.animateCamera(CameraUpdateFactory.zoomTo(10));
                Log.d("getnearbyplaces", String.valueOf(arrayList));
            }
        }
    }

这是例外

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.waqarraja.googlenearbyplaces, PID: 32030
                  java.lang.NullPointerException
                      at com.example.waqarraja.googlenearbyplaces.DataParser.getDuration(DataParser.java:25)
                      at com.example.waqarraja.googlenearbyplaces.DataParser.parseDirection(DataParser.java:120)
                      at com.example.waqarraja.googlenearbyplaces.GetDirectionsData.onPostExecute(GetDirectionsData.java:36)
                      at com.example.waqarraja.googlenearbyplaces.GetDirectionsData.onPostExecute(GetDirectionsData.java:13)
                      at android.os.AsyncTask.finish(AsyncTask.java:632)
                      at android.os.AsyncTask.access$600(AsyncTask.java:177)
                      at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5120)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
                      at dalvik.system.NativeStart.main(Native Method)
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/dalvikvm: GC_FOR_ALLOC freed 1814K, 17% free 20722K/24836K, paused 112ms, total 112ms
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}
D/DownloadURL: Returning data= {   "destination_addresses" : [],   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 39.33.172.119, with empty referer",   "origin_addresses" : [],   "rows" : [],   "status" : "REQUEST_DENIED"}

0 个答案:

没有答案