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); }
internal virtual void addPolygon() { int pointCount = 25; MapGeoPoint[] outerRing = new MapGeoPoint[pointCount]; MapGeoPoint[] innerRing = new MapGeoPoint[pointCount]; float rOuter = 20, rInner = 10; float cx = 30, cy = 30; // let's display circle for (int i = 0; i < pointCount; i++) { outerRing[i] = new MapGeoPoint(cx + System.Math.Sin(2 * System.Math.PI / pointCount * i) * rOuter, cy + System.Math.Cos(2 * System.Math.PI / pointCount * i) * rOuter); innerRing[i] = new MapGeoPoint(cx + System.Math.Sin(2 * System.Math.PI / pointCount * i) * rInner, cy + System.Math.Cos(2 * System.Math.PI / pointCount * i) * rInner); } MapGeoPoint[][] outerRings = new MapGeoPoint[][] { outerRing }; MapGeoPoint[][] innerRings = new MapGeoPoint[][] { innerRing }; GLMapVectorObject obj = GLMapVectorObject.CreatePolygonGeo(outerRings, innerRings); mapView.AddVectorObjectWithStyle(obj, GLMapVectorCascadeStyle.CreateStyle("area{fill-color:#10106050; fill-color:#10106050; width:4pt; color:green;}"), null); // #RRGGBBAA format }
public override void FillData(Java.Lang.Object marker, long nativeMarker) { if (marker is GLMapVectorObject) { GLMapVectorObject obj = (GLMapVectorObject)marker; GLMapMarkerStyleCollection.SetMarkerLocationFromVectorObject(nativeMarker, obj); } GLMapMarkerStyleCollection.SetMarkerStyle(nativeMarker, 0); }
internal virtual void addMarkerAsVectorObject(float x, float y) { if (markerLayer != null) { GLMapVectorObject[] newMarkers = new GLMapVectorObject[1]; newMarkers[0] = GLMapVectorObject.CreatePoint(mapView.ConvertDisplayToInternal(new MapPoint(x, y))); markerLayer.Modify(newMarkers, null, null, true, () => { Log.Debug("MarkerLayer", "Marker added"); }); } }
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); }
public override void FillData(Java.Lang.Object marker, long nativeMarker) { if (marker is MapPoint) { GLMapMarkerStyleCollection.SetMarkerLocation(nativeMarker, (MapPoint)marker); GLMapMarkerStyleCollection.SetMarkerText(nativeMarker, "Test", new Point(0, 0), textStyle); } else if (marker is GLMapVectorObject) { GLMapVectorObject obj = (GLMapVectorObject)marker; GLMapMarkerStyleCollection.SetMarkerLocationFromVectorObject(nativeMarker, obj); string name = obj.ValueForKey("name"); if (!string.ReferenceEquals(name, null)) { GLMapMarkerStyleCollection.SetMarkerText(nativeMarker, name, new Point(0, 15 / 2), textStyle); } } GLMapMarkerStyleCollection.SetMarkerStyle(nativeMarker, 0); }
internal virtual void addMultiline() { MapPoint[] line1 = new MapPoint[5]; line1[0] = MapPoint.CreateFromGeoCoordinates(53.8869, 27.7151); // Minsk line1[1] = MapPoint.CreateFromGeoCoordinates(50.4339, 30.5186); // Kiev line1[2] = MapPoint.CreateFromGeoCoordinates(52.2251, 21.0103); // Warsaw line1[3] = MapPoint.CreateFromGeoCoordinates(52.5037, 13.4102); // Berlin line1[4] = MapPoint.CreateFromGeoCoordinates(48.8505, 2.3343); // Paris MapPoint[] line2 = new MapPoint[3]; line2[0] = MapPoint.CreateFromGeoCoordinates(52.3690, 4.9021); // Amsterdam line2[1] = MapPoint.CreateFromGeoCoordinates(50.8263, 4.3458); // Brussel line2[2] = MapPoint.CreateFromGeoCoordinates(49.6072, 6.1296); // Luxembourg MapPoint[][] multiline = new MapPoint[][] { line1, line2 }; GLMapVectorObject obj = GLMapVectorObject.CreateMultiline(multiline); // style applied to all lines added. Style is string with mapcss rules. Read more in manual. mapView.AddVectorObjectWithStyle(obj, GLMapVectorCascadeStyle.CreateStyle("line{width: 2pt;color:green;layer:100;}"), null); }