0

I'm using GLMap to render over 5000 vector objects in an Android Application. Here is the framework I'm using: https://getyourmap.com/

Currently, I have Shapefiles which I convert with https://mapshaper.org/ to GeoJSON.

After the vector Objects being added to the map, my application start to lag, when I try to move the map. Can someone tell me, what I'm doing wrong here?

Here is my Code how I do this:

@Override
        protected GLMapVectorObjectList doInBackground(Void... voids) {
            GLMapDrawable drawable = null;
            try {

                GLMapVectorCascadeStyle style =
                        GLMapVectorCascadeStyle.createStyle(
                                "node[id=1]{icon-image:\"bus.svgpb\";icon-scale:0.5;icon-tint:green;text:eval(tag('text'));text-color:red;font-size:12;text-priority:100;}"
                                        + "node|z-9[id=2]{icon-image:\"bus.svgpb\";icon-scale:0.7;icon-tint:blue;text:eval(tag('text'));text-color:red;font-size:12;text-priority:100;}"
                                        + "line{linecap: round; width: 5pt; color:blue;}"
                                        + "area{fill-color:green; width:1pt; color:red;}");

                File polyFile = new File(Environment.getExternalStorageDirectory(),"GetYourMap/poly.geojson");

                BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(polyFile)));
                StringBuilder strBuilder = new StringBuilder();
                String line;
                while ((line = r.readLine()) != null) {
                    strBuilder.append(line);
                }

                final GLMapVectorObjectList listObjects = GLMapVectorObject.createFromGeoJSON(strBuilder.toString());

                for (long i = 0; i < listObjects.size(); ++i) {

                    drawable = new GLMapDrawable();
                    GLMapVectorObject test = listObjects.get(i);
                    drawable.setVectorObject(mGLMapView, listObjects.get(i), style, null);


                    publishProgress(drawable);
                }
                return listObjects;
            }
            catch(Exception e){

            }

            return null;
        }

        @Override
        protected void onProgressUpdate(GLMapDrawable... layer){
            if(layer != null){
               mGLMapView.add(layer[0]);
            }
        }


        @Override
        protected void onPostExecute(GLMapVectorObjectList listObjects){
            if (listObjects != null) {
                final GLMapBBox bbox = listObjects.getBBox();
                mapView.setMapCenter(bbox.center());
                mapView.setMapZoom(mapView.mapZoomForBBox(bbox, mapView.getWidth() + 1, mapView.getHeight() - 1));
                listObjects.dispose();
            }
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.