Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating and adding Markers to a Google Map
    primarykey
    data
    text
    <p>Adding a Google Map to my android app. Trying to create a new Marker and add it to the map and also to a list of Markers:</p> <pre><code>public void createMarkersFromList(){ for(int i = 0; i &lt; buildingList.size(); i++){ double lat = Double.parseDouble(buildingList.get(i).getLatitude()); double lng = Double.parseDouble(buildingList.get(i).getLongitude()); LatLng position = new LatLng(lat, lng); String name = buildingList.get(i).getName(); Marker m = fm.getMap().addMarker(new MarkerOptions() .position(position) .title(name)); markers.add(m); } } </code></pre> <p>But, I'm getting a NullPointerException error in the log and the app is crashing. What am I doing wrong?</p> <pre><code>11-24 23:13:51.171: E/dalvikvm(12071): The following issues were seen: 11-24 23:13:51.861: E/AndroidRuntime(12071): FATAL EXCEPTION: main 11-24 23:13:51.861: E/AndroidRuntime(12071): java.lang.NullPointerException: null reference 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.google.android.gms.internal.dm.e(Unknown Source) 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.google.android.gms.maps.model.Marker.&lt;init&gt;(Unknown Source) 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.example.uva_poops.ViewMap.createMarkersFromList(ViewMap.java:124) 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.example.uva_poops.ViewMap$GetBuildingList.onPostExecute(ViewMap.java:114) 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.example.uva_poops.ViewMap$GetBuildingList.onPostExecute(ViewMap.java:1) 11-24 23:13:51.861: E/AndroidRuntime(12071): at android.os.AsyncTask.finish(AsyncTask.java:631) 11-24 23:13:51.861: E/AndroidRuntime(12071): at android.os.AsyncTask.access$600(AsyncTask.java:177) 11-24 23:13:51.861: E/AndroidRuntime(12071): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644) 11-24 23:13:51.861: E/AndroidRuntime(12071): at android.os.Handler.dispatchMessage(Handler.java:99) 11-24 23:13:51.861: E/AndroidRuntime(12071): at android.os.Looper.loop(Looper.java:176) 11-24 23:13:51.861: E/AndroidRuntime(12071): at android.app.ActivityThread.main(ActivityThread.java:5279) 11-24 23:13:51.861: E/AndroidRuntime(12071): at java.lang.reflect.Method.invokeNative(Native Method) 11-24 23:13:51.861: E/AndroidRuntime(12071): at java.lang.reflect.Method.invoke(Method.java:511) 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 11-24 23:13:51.861: E/AndroidRuntime(12071): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 11-24 23:13:51.861: E/AndroidRuntime(12071): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload