簡體   English   中英

我在“展開地圖”項目中無法理解以下錯誤

[英]I can't understand the following Errors on my Unfolding Maps Project

我正在嘗試使用“展開地圖”顯示整個世界的地震數據,但我卡住了我不理解的錯誤。 請通過解決這些錯誤來幫助我

過去,我曾嘗試通過將boolean值設置為true來離線運行Maps,但我沒有工作。

問題出自Coursera,並采用作業形式。 我正在為此作業進行故障排除

Using OpenGLMapDisplay with processing.opengl.PGraphics3D
Exception in thread "Animation Thread" java.lang.NullPointerException
    at module3.EarthquakeCityMap.setup(EarthquakeCityMap.java:102)
    at processing.core.PApplet.handleDraw(PApplet.java:2365)
    at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:873)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:690)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:672)
    at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1383)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1277)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
    at javax.media.opengl.awt.GLCanvas$11.run(GLCanvas.java:1394)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

 List<Marker> markers = new ArrayList<Marker>();

    //Use provided parser to collect properties for each earthquake
    //PointFeatures have a getLocation method
    List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL);

    for (PointFeature eq: earthquakes) {
        markers.add(new SimplePointMarker(eq.getLocation(), eq.getProperties()));
    }

    // Add the markers to the map so that they are displayed
    map.addMarkers(markers);



int yellow = color(255,255,0);
int gray = color(150,150,150);

for(Marker mk : markers) {
    if ((int) mk.getProperty("year") > 2000) {
        mk.setColor(yellow);
    }
    else {
        mk.setColor(gray);
    }
}


}


@SuppressWarnings("unused")
private SimplePointMarker createMarker(PointFeature feature)
{  
    // To print all of the features in a PointFeature (so you can see what they are)
    // uncomment the line below.  Note this will only print if you call createMarker 
    // from setup
    //System.out.println(feature.getProperties());

    // Create a new SimplePointMarker at the location given by the PointFeature
    SimplePointMarker marker = new SimplePointMarker(feature.getLocation());

    Object magObj = feature.getProperty("magnitude");
    float mag = Float.parseFloat(magObj.toString());

    // Here is an example of how to use Processing's color method to generate 
    // an int that represents the color yellow.  
    int yellow = color(255, 255, 0);


    // Finally return the marker
    return marker;
}

public void draw() {
    background(10);
    map.draw();
}

這個例外

Exception in thread "Animation Thread" java.lang.NullPointerException

這是哪里

at module3.EarthquakeCityMap.setup(EarthquakeCityMap.java:102)

因此,您需要進入“ EarthquakeCityMap.java”的第102行,查找可能導致Null Pointer異常的原因

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM