Consuming TopoJSON in ol3

So let's code an ol3 example. Once again, we are merely modifying a layer definition:

new ol.layer.Vector({ 
//projection: proj,
source: new ol.source.Vector({
format: new ol.format.TopoJSON(),
url: 'data/topojson.json',
attributions: [
new ol.Attribution({
html: 'Mastering PostGIS - TopoJSON'
})
]
}),
style: [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 0, 1)',
width: 0.5
})
})
]
})
Because we need the JSON to be read by our application, make sure that the file is available under data/topojson.json in the root of our web example.

In order to preview the example, navigate to the example's folder, run sencha app watch, and navigate to http://localhost:1841/apps/07_ol3_topojson/. You should see a similar output to the following:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset