protected override GLMapMarkerLayer RunInBackground(params Java.Lang.Void[] voids) { GLMapMarkerLayer rv; try { Log.Warn("GLMapView", "Start parsing"); GLMapVectorObjectList objects = GLMapVectorObject.CreateFromGeoJSONStream(outerInstance.Assets.Open("cluster_data.json")); Log.Warn("GLMapView", "Finish parsing"); GLMapBBox bbox = objects.BBox; outerInstance.RunOnUiThread(() => { outerInstance.mapView.SetMapCenter(bbox.Center(), false); outerInstance.mapView.SetMapZoom(outerInstance.mapView.MapZoomForBBox(bbox, outerInstance.mapView.Width, outerInstance.mapView.Height), false); }); Log.Warn("GLMapView", "Start creating layer"); rv = new GLMapMarkerLayer(objects.ToArray(), style); Log.Warn("GLMapView", "Finish creating layer"); objects.Dispose(); } catch (Java.Lang.Exception) { rv = null; } return(rv); }
private void loadGeoJSON() { GLMapVectorObjectList objects = GLMapVectorObject.CreateFromGeoJSON( "[{\"type\": \"Feature\", \"geometry\": {\"type\": \"Point\", \"coordinates\": [30.5186, 50.4339]}, \"properties\": {\"id\": \"1\", \"text\": \"test1\"}}," + "{\"type\": \"Feature\", \"geometry\": {\"type\": \"Point\", \"coordinates\": [27.7151, 53.8869]}, \"properties\": {\"id\": \"2\", \"text\": \"test2\"}}," + "{\"type\":\"LineString\",\"coordinates\": [ [27.7151, 53.8869], [30.5186, 50.4339], [21.0103, 52.2251], [13.4102, 52.5037], [2.3343, 48.8505]]}," + "{\"type\":\"Polygon\",\"coordinates\":[[ [0.0, 10.0], [10.0, 10.0], [10.0, 20.0], [0.0, 20.0] ],[ [2.0, 12.0], [ 8.0, 12.0], [ 8.0, 18.0], [2.0, 18.0] ]]}]"); 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;}"); mapView.AddVectorObjectsWithStyle(objects.ToArray(), style); }