Create markers from features manually (for Points)

edited October 2017 in Library Questions

Hi!

I have a geojson data that has multiple points that are classified into "red", "blue" and "green". Is there a way to create markers manually for the points similar to the example code for SimpleLineMarkers? I got stuck 'cause most of the examples I saw were for SimplePointMarker which is for one location only. Thank you!

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

// Load features from GeoJSON
List<Feature> transitLines = GeoJSONReader.loadData(this, "MBTARapidTransitLines.json");

// Create markers from features, and use LINE property to color the markers.
for (Feature feature : transitLines) {
    ShapeFeature lineFeature = (ShapeFeature) feature;

    SimpleLinesMarker m = new SimpleLinesMarker(lineFeature.getLocations());
    String lineColor = lineFeature.getStringProperty("LINE");
    int color = 0;
    // Original MBTA colors
    if (lineColor.equals("BLUE")) {
        color = color(44, 91, 167);
    }
    if (lineColor.equals("RED")) {
        color = color(233, 57, 35);
    }
    if (lineColor.equals("GREEN")) {
        color = color(59, 130, 79);
    }
    if (lineColor.equals("SILVER")) {
        color = color(154, 156, 157);
    }
    if (lineColor.equals("ORANGE")) {
        color = color(238, 137, 40);
    }
    m.setColor(color);
    m.setStrokeWeight(5);
    transitMarkers.add(m);
}

map.addMarkers(transitMarkers);
Sign In or Register to comment.