DevWizard
DevWizard

Reputation: 695

Openlayers 4 vector map

I'm creating a dashboard site and I'm using a vector layer to select a wards (in this prototype I'm using ESSEX UK with all the wards inside, see image)

enter image description here

and this is the code I'm using.

http://openlayers.org/en/latest/examples/select-features.html?q=selec

the problem is that when I create the geojson file from a map file (the only field inside the map file is the ward name and the code,not too much info) the size start to be a bit big for just this piece of map and is pretty slow to load the map and once I tried to load a bigger file (almost 6mb) and Openlayers fails to load it, now I need to create another prototype but for the whole UK (just regions, no wards).

which format are supported from OL4 to vector? can I achieve something like this with another format that is not GeoJson?

I need to be able to click and get back at least the name of where I'm clicking and use it to launch my other function that needs the name to works.

Upvotes: 0

Views: 293

Answers (1)

fradal83
fradal83

Reputation: 2022

There are many ways to address the performance problems of client side rendering of vector data.

First of all, it's a bit weird that you can't render 6mb of vector data with openlayers. In my experience (mostly with OpenLayers 2), 6mb isn't that much. However, it heavily depends on client capabilities. What's the problem with loading? Timeout? Freeze? Unresponsive pan/zoom?

You could render data server side, using WMS or tiles. You could use mapserver or geoserver for example. Then, to select objects, you could use a GetFeatureInfo request.

Otherwise, as suggested by pavankguduru, you could try with the vector tiles format.

Probably, your vector data is too "detailed" for your purposes. You could simplify them to reduce the number of points of each geometry. See GRASS's v.generalize tool.

You could also use an aggregate version of your data (regions) until the user zoom in.

IMHO, if your application needs to run on old browsers/PC, then you need to render server-side.

Upvotes: 2

Related Questions