1

I have a ushahidi deployment and i am using Openlayers + ushahidi api to show the reports in a separate map along with other features.

i have queried the data from ushahidi api and made a vector layer. the layer has data but it not showing up.

This part gets the data from ushahidi

var roadreportrequest = OpenLayers.Request.GET({
url: '../roadreport/api/?task=incidents',
async: false,
success: function(Request) {
    // alert("success");
    roadreportjson = JSON.parse(Request.responseText);
},
failure: function() {
    alert("failed to load data from roadrepoter");
    roadreportjson = {}
}

});

and this part converts it to vector layer

var roadreport_vector = new OpenLayers.Layer.Vector('RoadReporter Reports');

for (incident_index in roadreportjson.payload.incidents) {
// console.log(incident_index, roadreportjson.payload.incidents[incident_index]);
incident = roadreportjson.payload.incidents[incident_index];
roadreport_vector.addFeatures([
    new OpenLayers.Feature.Vector(
        new OpenLayers.Geometry.Point(incident.incident.locationlongitude, incident.incident.locationlatitude),
        incident)
])
}
map.addLayer(roadreport_vector);

There is data in the layer, i have checked the console and this code to pan the map also works.

map.panTo(new OpenLayers.LonLat(roadreport_vector.features[2].geometry.x, roadreport_vector.features[2].geometry.y))

My issue is that i am expecting the data to be shown up as on the map(the default orange circles), but it is not showing up.

1 Answer 1

1

It was a matter of different Projection systems. Ushahidid stores and returns data in wgs 84(EPSG;4326) system whereas the map was on spherical mercator system (EPSG:900913).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.