Saturday 30 March 2019

Integrate GeoJSON file with openlayers.protocol.http


I've got a problem with (the title says it) integrating a geojson file in my openlayers map. I have to use the openlayers.protocol.http way. I examined lots of examples on the web (and on stackexchange) but I cannot figure out what the problem with my exact code is. it shows the layer in the layerswitcher, but it doesn't show the features.


I hope someone can find the error. Here's my code (relating geojson):


WebMapping - Übung 12












Ihr Browser unterstützt keine Inlineframes



Wikipedia-Integration in OpenLayers








Answer



Well, here is my working example. First of all, your code have some errors. Read carefully this to discover what was changed, because I don't have time to comment and explain in details.


























And the file with GeoJSON:



{"type":"FeatureCollection",
"features":[
{"type":"Feature",
"properties":{
"name":"TRON-02",
"color":"green",
"size":15
},
"geometry":{
"type":"Point",

"coordinates":[8.692, 49.412]
}
}
]
}

Feel free to ask anything you don't understand. 1) Format your HTML correctly. 2) Your map don't call the correct DIV tag to render. 3) I put a projection in the vector. 4) CHanged the coordinates to my country (eheh) so you will know where to go the next Football World Cup.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...