public MapMarkerGump(Mobile from, MapMarker mapmarker) : base(500, 350) { m_From = from; m_MapMarker = mapmarker; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; AddPage(0); AddBackground(104, 11, 275, 291, 2620); AddImage(-38, -38, 666); //garg statue AddItem(112, 20, 9123); //drag logo AddLabel(188, 17, 1160, @"MapMarker Viewer"); AddButton(359, 19, 3, 4, 0, GumpButtonType.Reply, 0); //X close button AddLabel(202, 39, 1160, @"Name Notation:"); AddBackground(158, 61, 200, 20, 9300); AddTextEntry(158, 61, 200, 20, 0, 0, @mapmarker.MapMarkerNameAddon, 22); AddLabel(212, 88, 1160, @"Description:"); AddBackground(110, 110, 264, 150, 9300); AddTextEntry(120, 110, 243, 140, 0, 1, @mapmarker.MapMarkerNote); AddButton(135, 265, 9904, 9903, 1, GumpButtonType.Reply, 0); //Save AddLabel(170, 266, 1152, @"Save Changes"); }
public override View GetMarkerView(MapMarker marker, PointF point) { LinearLayout layout = new LinearLayout(context); ImageView imageView = new ImageView(context); imageView.SetImageResource(Resource.Drawable.pin); float density = context.Resources.DisplayMetrics.Density; int layoutWidth = (int)(15 * density); int layoutHeight = (int)(40 * density); int imageHeight = (int)(20 * density); var layoutParams = new LinearLayout.LayoutParams(layoutWidth, layoutHeight); layout.Orientation = Orientation.Vertical; layout.SetMinimumHeight(layoutHeight); layout.SetMinimumWidth(layoutWidth); layout.LayoutParameters = layoutParams; var imageViewParams = new LinearLayout.LayoutParams(layoutWidth, imageHeight); imageView.LayoutParameters = imageViewParams; imageView.SetMinimumHeight(imageHeight); imageView.SetMinimumWidth(layoutWidth); layout.AddView(imageView); return(layout); }
public void HideInteraction() { raycaster.eventMask = LayerMask.GetMask("MapMarker"); _mapMovement.enabled = true; activeMarker = null; Help.SetActive(false); }
void Toggle() { this.clickedThisLoop = true; if (this.On == false) { if (EditorManager.TileMode) { this.GoOn(); } } else { if (EditorManager.TileMode) { this.On = false; this.Sprite.Texture = EditorManager.defaultTile; this.TileType = TileType.Empty; this.marker = null; } else { ToggleMarker(); } //ToggleSelection(); } }
public async Task <MapMarker> CreateMapMarkerAsync( NaheulbookExecutionContext executionContext, int mapLayerId, MapMarkerRequest request ) { using var uow = _unitOfWorkFactory.CreateUnitOfWork(); var mapLayer = await uow.MapLayers.GetAsync(mapLayerId); if (mapLayer == null) { throw new MapLayerNotFoundException(mapLayerId); } await _authorizationUtil.EnsureCanEditMapLayerAsync(executionContext, mapLayer); var mapMarker = new MapMarker { LayerId = mapLayerId, Name = request.Name, Description = request.Description, Type = request.Type, MarkerInfo = _jsonUtil.SerializeNonNull(request.MarkerInfo) }; uow.MapMarkers.Add(mapMarker); await uow.SaveChangesAsync(); return(mapMarker); }
public void convert(string name, ParameterParser args, Stream from, Stream to) { var obj = MapMarker.ReadFile(from); byte[] buffer = Encoding.Default.GetBytes(Utils.convertToJSON(obj)); to.Write(buffer, 0, buffer.Length); }
public void read() { MemoryStream stream = new MemoryStream(sampleData, false); MapMarker[] mapMarkers = MapMarker.ReadFile(stream); testMarkers(mapMarkers); }
/// <summary> /// Scale a map marker /// </summary> /// <param name="marker">Marker</param> /// <param name="scaleX">ScaleY</param> /// <param name="scaleY">ScaleY</param> private void ScaleMapMarker(MapMarker marker, float scaleX, float scaleY) { marker.X *= scaleX; marker.Y *= scaleY; if (marker.ChapterPixelCoords == null) { return; } foreach (MapMarkerChapterPixelCoords curCoords in marker.ChapterPixelCoords) { curCoords.X *= scaleX; curCoords.Y *= scaleY; } if (marker.Geometry != null) { foreach (MarkerGeometry curGeom in marker.Geometry) { foreach (MarkerGeometryPosition curPos in curGeom.Positions) { curPos.X *= scaleX; curPos.Y *= scaleY; } } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Native.Initialize(); _mapView = new MapView(this, new MapViewSurface(this)); _mapView.MapTilt = 0; _mapView.MapCenter = new GeoCoordinate(53.770226, 20.490189); _mapView.MapZoom = 12; _mapView.Map = new Map(); _mapView.MapAllowZoom = true; _mapLayer = _mapView.Map.AddLayerTile("http://a.tile.openstreetmap.de/tiles/osmde/{0}/{1}/{2}.png"); _mapView.MapTapEvent += MapViewTapEvent; using (var bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.pin)) { var marker = new MapMarker(this, new GeoCoordinate(53.770226, 20.490189), MapMarkerAlignmentType.CenterBottom, bitmap); _mapView.AddMarker(marker); } var layout = FindViewById <RelativeLayout>(Resource.Id.Mapka); layout.AddView(_mapView); }
public async Task <IEnumerable <MapMarker> > GetMarkers(IEnumerable <EstablishmentModel> establishments) { IList <MapMarker> markers = new List <MapMarker>(); foreach (var establishment in establishments) { var inputAddress = establishment.Address.GetFormatted(); var addresses = await _geocoder.GeocodeAsync(inputAddress); var result = addresses.First(); var marker = new MapMarker { Latitude = result.Coordinates.Latitude, Longitude = result.Coordinates.Longitude, ShortCode = establishment.ShortCode, Name = establishment.Name, Description = establishment.Description, Type = establishment.Type, Logo = establishment.Logo, FormattedAddress = inputAddress, BusinessHours = establishment.BusinessHours, }; markers.Add(marker); } return(markers); }
void AddMarkers() { var from = new GeoCoordinate(51.261203, 4.780760); var to = new GeoCoordinate(51.267797, 4.801362); var box = new GeoCoordinateBox(from, to); _mapView.ClearMarkers(); MapMarker marker; for (int idx = 0; idx < 20; idx++) { var pos = box.GenerateRandomIn(); marker = new MapMarker(this, pos, MapControlAlignmentType.CenterBottom, this.Resources, Resource.Drawable.marker); var popupView = marker.AddNewPopup(300, 300); var textView = new TextView(this.ApplicationContext); textView.Text = "Some popup text here."; textView.TextSize = 10; textView.SetTextColor(global::Android.Graphics.Color.Black); popupView.AddView(textView); _mapView.AddMarker(marker); } }
public void ShowInteraction(MapMarker marker) { activeMarker = marker; raycaster.eventMask = LayerMask.GetMask(); _mapMovement.enabled = false; //resourceLocationData.Find((x) => { return x.ResourceType == marker.resourceType; }).InteractUI.Show(this); }
// Start is called before the first frame update void Start() { instance = this; rb2d = GetComponent <Rigidbody2D>(); PV = GetComponent <PhotonView>(); foreach (TeamTokenCaptain ttc in FindObjectsOfType <TeamTokenCaptain>()) { teamCaptains.Add(ttc, 0); } updateDirection(PV.IsMine); contestEffect.enabled = false; pathGenerator.onMapPathGenerated += updatePositionOnPath; if (pathGenerator.mapPath != null) { updatePositionOnPath(pathGenerator.mapPath); } //Display for on the caravan gameObject.FindComponent <CaravanMapMarkerDisplay>()?.Init(this); //Marker MapMarker mapMarker = MapMarkerManager.CreateMapMarker( PV, transform, caravanMarkerInfo ); GameObject balloons = Instantiate(caravanMarkerBalloonPrefab); balloons.transform.parent = mapMarker.iconSR.transform; balloons.transform.localPosition = Vector2.zero; balloons.GetComponent <CaravanMapMarkerDisplay>().Init(this); }
// Start is called before the first frame update void Start() { healthPool = GetComponent <HealthPool>(); teamTokenCaptain = GetComponent <TeamTokenCaptain>(); healthPool.onDied += checkGameOver; //Team Token Captains teamCaptains = FindObjectsOfType <TeamTokenCaptain>().ToList(); //Text Map Name txtMapName = gameObject.FindComponent <TMP_Text>(); MapGenerator mapGenerator = FindObjectOfType <MapGenerator>(); txtMapName.text = mapGenerator.mapName; mapGenerator.onMapNameChanged += (mapName) => txtMapName.text = mapName; //Marker MapMarker mapMarker = MapMarkerManager.CreateMapMarker( PhotonView.Get(gameObject), transform.position, flagMarkerInfo ); GameObject balloons = Instantiate(flagMarkerBalloonPrefab); balloons.transform.parent = mapMarker.iconSR.transform; balloons.transform.localPosition = Vector2.zero; balloons.GetComponent <FlagMapMarkerDisplay>().Init(this); }
public virtual MapMarkerBuilder Add() { var item = new MapMarker(this.map); container.Add(item); return new MapMarkerBuilder(item); }
private void MapViewTapEvent(GeoCoordinate coordinate) { using (var bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.pin)) { var marker = new MapMarker(this, coordinate, MapMarkerAlignmentType.CenterBottom, bitmap); _mapView.AddMarker(marker); } }
public void ToStringTest() { var mapMarker = new MapMarker(); var toString = mapMarker.ToString(); Assert.IsNull(toString); }
private MapMarker CreateMapMarkerPos(PhotonView placer, Vector2 pos, MapMarkerInfo markerInfo) { MapMarker marker = GetOrCreateMapMarker(placer.ViewID); marker.Init(markerInfo, TeamToken.getTeamToken(placer.gameObject)); //placer.teamCaptain.teamColor, Color.white); marker.Mark(pos); return(marker); }
private MapMarker CreateMapMarkerFollow(PhotonView placer, Transform follow, MapMarkerInfo markerInfo) { MapMarker marker = GetOrCreateMapMarker(placer.ViewID); marker.Init(markerInfo, TeamToken.getTeamToken(placer.gameObject)); //placer.teamCaptain.teamColor, Color.white); marker.Mark(follow); return(marker); }
public virtual MapMarkerBuilder Add() { var item = new MapMarker(this.map); container.Add(item); return(new MapMarkerBuilder(item)); }
private static Point GetClientPoint(MapMarker marker) { var gmap = marker.Map; var proj = marker.Map.MapProvider.Projection; var clientPos = proj.FromLatLngToPixel(marker.Position, (int)gmap.Zoom); return(new Point(clientPos.X, clientPos.Y)); }
/// <summary> /// Copies the base marker attributes from one marker to another marker /// </summary> /// <param name="targetMarker">Marker to copy to</param> /// <param name="sourceMarker">Marker to copy from</param> private void CopyBaseMarkerAttributes(MapMarker targetMarker, MapMarker sourceMarker) { targetMarker.X = sourceMarker.X; targetMarker.Y = sourceMarker.Y; targetMarker.AddedInChapter = sourceMarker.AddedInChapter; targetMarker.ChapterPixelCoords = sourceMarker.ChapterPixelCoords; targetMarker.DeletedInChapter = sourceMarker.DeletedInChapter; }
private void button1_Click_1(object sender, EventArgs e) { textBox6.Clear(); textBox7.Clear(); localeProb = new MapMarker(); localeProb.ShowDialog(); textBox6.Text = localeProb.Lng; textBox7.Text = localeProb.Lat; }
public JsonResult GetPlace_ids() { MapMarker marker = new MapMarker(); marker.Place_IDs = ServiceSchool.GetSchools().Select(x => x.PlaceId).ToList(); marker.Titles = ServiceSchool.GetSchools().Select(x => x.Name).ToList(); return(Json(marker, JsonRequestBehavior.AllowGet)); }
public void CompleteInteraction() { if (activeMarker != null) { placeMarkers.Remove(activeMarker.gameObject); Destroy(activeMarker.gameObject); activeMarker = null; } }
public MarkerSpace(MapMarker marker, Point position, Size size, List <LabelRect> availablePlaces) { Marker = marker; Position = position; Size = size; Rect = new Rect(position.X - size.Width / 2, position.Y - size.Height / 2, size.Width, size.Height); AvailablePlaces = availablePlaces; DefaultLabelPlace = availablePlaces[0]; }
public FileResult DisplayParkingLotsOnMap() { List <Lot> allLots = iLotRepo.ListAllLots(); List <MapMarker> mapMarkers = new List <MapMarker>(); foreach (Lot eachLot in allLots) { MapMarker eachMapMarker = new MapMarker(); List <Location> locations = new List <Location>(); Location eachLocation = new Location(eachLot.LotAddress); locations.Add(eachLocation); eachMapMarker.Locations = locations; eachMapMarker.Label = eachLot.LotNumber; //can only be 0-9 or A-Z eachMapMarker.Color = GoogleApi.Entities.Maps.StaticMaps.Request.Enums.MapColor.Blue; mapMarkers.Add(eachMapMarker); } StaticMapsRequest staticMapsRequest = new StaticMapsRequest(); if (!String.IsNullOrEmpty(HttpContext.Session.GetString("WVUEmployeeID"))) { string WVUEmployeeID = HttpContext.Session.GetString("WVUEmployeeID"); WVUEmployee employee = iApplicationUserRepo.FindWvuEmployee(WVUEmployeeID); string origin = employee.Department.DepartmentAddress; MapMarker eachMapMarker = new MapMarker(); List <Location> locations = new List <Location>(); Location employeeLocation = new Location(origin); locations.Add(employeeLocation); eachMapMarker.Locations = locations; eachMapMarker.Label = "E"; //can only be 0-9 or A-Z eachMapMarker.Color = GoogleApi.Entities.Maps.StaticMaps.Request.Enums.MapColor.Purple; mapMarkers.Add(eachMapMarker); staticMapsRequest.Center = employeeLocation; } staticMapsRequest.Key = "AIzaSyBRT65jDLR_mhb4yzGbMBMaIZALz57028A"; staticMapsRequest.Markers = mapMarkers; staticMapsRequest.Type = GoogleApi.Entities.Maps.StaticMaps.Request.Enums.MapType.Roadmap; StaticMapsResponse response = GoogleApi.GoogleMaps.StaticMaps.Query(staticMapsRequest); var file = response.Buffer; return(File(file, "image/jpeg")); }
void AddMapMarker(int x, int y, MapMarkerType type) { MapMarker mapMarker = new MapMarker { Type = type, Location = new Point2D(x, y) }; mapMarkers.Add(mapMarker); }
public static void UpdateArea(DatabaseBuilder builder, dynamic npc, Saint.Map sMap, double mapX, double mapY) { var marker = MapMarker.FindClosest(builder, sMap, mapX, mapY); if (marker != null) { npc.areaid = marker.PlaceName.Key; builder.Db.AddLocationReference(marker.PlaceName.Key); } }
void ToggleMarker() { if (this.marker != null) { this.marker = null; } else { this.marker = new MapMarker(EditorManager.currentMarker.Name, this.StartingPosition, EditorManager.currentMarker.Texture, EditorManager.currentMarker.MarkerType); //this.marker.Texture = EditorManager.currentMarker.Texture; } }
private static void SetLabel(MapMarker marker, Point labelPosition) { var element = marker.MarkerContainer.LabelContent as FrameworkElement; if (element == null) { return; } var markerPos = GetClientPoint(marker); marker.MarkerContainer.LabelOffset = new Point(labelPosition.X - markerPos.X, labelPosition.Y - markerPos.Y); }
//Sorts the array of MapMarker by the starting value private void SortMapMarkers(){ MapMarker tempMapMarker = new MapMarker(); for (int i = 0; i <= numNotes; i++) { for (int j = 0; j < numNotes; j++) { if (mapMarker[j].start > mapMarker[j + 1].start) { //swap tempMapMarker = mapMarker[j]; mapMarker[j] = mapMarker[j + 1]; mapMarker[j + 1] = tempMapMarker; } } } }
public void MarksMapSpaceFillsMapCorrectlyInclusive() { var headLocation = new MapLocation(50, 50); var newLocation = new MapLocation(50, 54); var fillValue = 1; var inclusive = true; var map = new Map(gameConfig.MapConfig); var mapMarker = new MapMarker(map); var incrementor = new MapLocation(0, 1); map[headLocation] = -1; mapMarker.MarkArea(headLocation, newLocation, fillValue, inclusive); Assert.Equal(map[newLocation], 0); Assert.Equal(map[headLocation], -1); for (MapLocation i = headLocation + incrementor; !i.SameAs(newLocation); i += incrementor) { Assert.Equal(map[i], fillValue); } }
/// <summary> /// Raises the create event. /// </summary> /// <param name="bundle">Bundle.</param> protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // hide title bar. this.RequestWindowFeature(global::Android.Views.WindowFeatures.NoTitle); // initialize map. var map = new Map(); map.AddLayer(new LayerMBTile(OsmSharp.Android.UI.Data.SQLite.SQLiteConnection.CreateFrom( Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.kempen.mbtiles"), "map"))); // add a tile layer. //var layer = new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png"); //map.AddLayer(layer); //layer.IsVisible = false; //map.AddLayer(new LayerTile(@"http://a.tiles.mapbox.com/v3/osmsharp.i8ckml0l/{0}/{1}/{2}.png")); //map.AddLayerGpx(Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.regression1.gpx")); // // add an on-line osm-data->mapCSS translation layer. //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter)); // add a preprocessed vector data file. //var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.default.map"); //map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true))); //// define dummy from and to points. //var from = new GeoCoordinate(51.261203, 4.780760); //var to = new GeoCoordinate(51.267797, 4.801362); //// deserialize the preprocessed graph. //var routingSerializer = new CHEdgeDataDataSourceSerializer(); //var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Android.UI.Sample.kempen-big.osm.pbf.routing"); //var graphDeserialized = routingSerializer.Deserialize(graphStream, true); //// initialize router. //_router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter()); //// resolve points. //var routerPoint1 = _router.Resolve(Vehicle.Car, from); //var routerPoint2 = _router.Resolve(Vehicle.Car, to); //// calculate route. //var route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2); //// add a router layer. //_routeLayer = new LayerRoute(map.Projection); //_routeLayer.AddRoute(route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12); //map.AddLayer(_routeLayer); // define the mapview. _mapView = new MapView(this, new MapViewSurface(this)); //_mapView = new MapView(this, new MapViewGLSurface(this)); //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent); _mapView.MapTapEvent += _mapView_MapTapEvent; _mapView.Map = map; //_mapView.MapMaxZoomLevel = 20; //_mapView.MapMinZoomLevel = 10; _mapView.MapTilt = 0; _mapView.MapCenter = new GeoCoordinate(51.261203, 4.780760); _mapView.MapZoom = 16; _mapView.MapAllowTilt = false; _mapView.MapTouchedUp += _mapView_MapTouchedUp; _mapView.MapTouched += _mapView_MapTouched; _mapView.MapTouchedDown += _mapView_MapTouchedDown; // AddMarkers(); // AddControls(); // initialize a text view to display routing instructions. _textView = new TextView(this); _textView.SetBackgroundColor(global::Android.Graphics.Color.White); _textView.SetTextColor(global::Android.Graphics.Color.Black); // add the mapview to the linear layout. var layout = new RelativeLayout(this); //layout.Orientation = Orientation.Vertical; //layout.AddView(_textView); layout.AddView(_mapView); // create the route tracker animator. //_routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17); // simulate a mapzoom change every 5 seconds. //Timer timer = new Timer(5000); //timer.Elapsed += new ElapsedEventHandler(TimerHandler); //timer.Start(); _centerMarker = _mapView.AddMarker(_mapView.MapCenter); _mapView.MapInitialized += _mapView_MapInitialized; SetContentView(layout); }
void AddMarkers() { var from = new GeoCoordinate(51.261203, 4.780760); var to = new GeoCoordinate(51.267797, 4.801362); var box = new GeoCoordinateBox(from, to); _mapView.ClearMarkers(); MapMarker marker; for (int idx = 0; idx < 20; idx++) { var pos = box.GenerateRandomIn(); marker = new MapMarker(this, pos, MapControlAlignmentType.CenterBottom, this.Resources, Resource.Drawable.marker); var popupView = marker.AddNewPopup(300, 300); var textView = new TextView(this.ApplicationContext); textView.Text = "Some popup text here."; textView.TextSize = 10; textView.SetTextColor(global::Android.Graphics.Color.Black); popupView.AddView(textView); _mapView.AddMarker(marker); } }
public MapMarkerBuilder(MapMarker settings) { container = settings; }
/// <summary> /// Initializes the View property. /// </summary> public override void LoadView() { base.LoadView (); // initialize OsmSharp native hooks. Native.Initialize(); // enable the loggging. OsmSharp.Logging.Log.Enable(); OsmSharp.Logging.Log.RegisterListener(new OsmSharp.iOS.UI.Log.ConsoleTraceListener()); // initialize map. var map = new Map(); // add a tile layer. map.AddLayer(new LayerTile(@"http://192.168.43.155:1234/default/{0}/{1}/{2}.png")); // map.AddLayer(new LayerMBTile(SQLiteConnection.CreateFrom( // Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.iOS.UI.Sample.kempen.mbtiles"), "map"))); // add an online osm-data->mapCSS translation layer. //map.AddLayer(new OsmLayer(dataSource, mapCSSInterpreter)); // add a pre-processed vector data file. // var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream( // "OsmSharp.iOS.UI.Sample.default.map"); // map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true))); // var primitivesLayer = new LayerPrimitives(map.Projection); // primitivesLayer.AddPoint(new GeoCoordinate(51.26371, 4.78601), 10, // SimpleColor.FromKnownColor(KnownColor.Blue).Value); // map.AddLayer(primitivesLayer); // // define dummy from and to points. var from = new GeoCoordinate(51.261203, 4.780760); var to = new GeoCoordinate(51.267797, 4.801362); // // // deserialize the pre-processed graph. // var routingSerializer = new CHEdgeDataDataSourceSerializer(false); // TagsCollectionBase metaData = null; // var graphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream( // "OsmSharp.iOS.UI.Sample.kempen-big.osm.pbf.routing"); // var graphDeserialized = routingSerializer.Deserialize(graphStream, out metaData, true); // // // initialize router. // _router = Router.CreateCHFrom(graphDeserialized, new CHRouter(), new OsmRoutingInterpreter()); // // // resolve points. // RouterPoint routerPoint1 = _router.Resolve(Vehicle.Car, from); // RouterPoint routerPoint2 = _router.Resolve(Vehicle.Car, to); // // // calculate route. // Route route = _router.Calculate(Vehicle.Car, routerPoint1, routerPoint2); // RouteTracker routeTracker = new RouteTracker(route, new OsmRoutingInterpreter()); // _enumerator = route.GetRouteEnumerable(10).GetEnumerator(); // // // add a router layer. // _routeLayer = new LayerRoute(map.Projection); // _routeLayer.AddRoute (route, SimpleColor.FromKnownColor(KnownColor.Blue, 125).Value, 12); // map.AddLayer(_routeLayer); // define the mapview. _mapView = new MapView(); //_mapView.MapTapEvent += new MapViewEvents.MapTapEventDelegate(_mapView_MapTapEvent); _mapView.MapAllowTilt = false; _mapView.Map = map; _mapView.MapMaxZoomLevel = 19; _mapView.MapMinZoomLevel = 0; _mapView.MapTilt = 0; _mapView.MapCenter = new GeoCoordinate(51.2633, 4.7853); _mapView.MapZoom = 18; _mapView.MapInitialized += _mapView_MapInitialized; // add markers. var marker = _mapView.AddMarker (from); var popupTextView = new UITextView(); popupTextView.Text = "Hey, this is popup text!"; popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f); marker.AddPopup(popupTextView, 100, 100); marker = _mapView.AddMarker (to); popupTextView = new UITextView(); popupTextView.Text = "Hey, this is another popup text!"; popupTextView.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f); marker.AddPopup(popupTextView, 100, 100); this.AddMarkers(); // add center marker. _centerMarker = _mapView.AddMarker(_mapView.MapCenter); // create the route tracker animator. // _routeTrackerAnimator = new RouteTrackerAnimator(_mapView, routeTracker, 5, 17); // // simulate a number of gps-location update along the calculated route. // Timer timer = new Timer(250); // timer.Elapsed += new ElapsedEventHandler(TimerHandler); // timer.Start(); View = _mapView; }
public void checkIn(MapMarker marker) { if (!playerTransform) { //error was already fired in Awake() return; } float scaledRadarDistance = radarDistance * scale; float scaledMaxRadarDistance = maxRadarDistance * scale; if (marker.isActive) { float distance = distanceToPlayer(marker.getPosition()); float opacity = 1.0f; if (distance > scaledRadarDistance) { if (hideOutOfRadius) { if (marker.isVisible()) { marker.hide(); } return; } else { if (distance > scaledMaxRadarDistance) { if (marker.isVisible()) { marker.hide(); } return; } else { if (useOpacity) { float opacityRange = scaledMaxRadarDistance - scaledRadarDistance; if (opacityRange <= 0) { Debug.LogError("Max radar distance should be bigger than radar distance"); return; } else { float distanceDiff = distance - scaledRadarDistance; opacity = 1 - (distanceDiff / opacityRange); if (opacity < minimalOpacity) { opacity = minimalOpacity; } } } distance = scaledRadarDistance; } } } if (!marker.isVisible()) { marker.show(); } Vector3 posDif = marker.getPosition() - playerTransform.position; Vector3 newPos = new Vector3(posDif.x, posDif.z, 0); newPos.Normalize(); float markerRadius = (marker.markerSize / 2); float newLen = (distance / scaledRadarDistance) * (innerMapRadius - markerRadius); newPos *= newLen; marker.setLocalPos(newPos); marker.setOpacity(opacity); } else { if (marker.isVisible()) { marker.hide(); } } }
private void RefreshOverlays(bool clear) { if (clear || MapControlChanged) { ClearOverlays(); ResetMapControl(); } if (!m_showPage) return; IGPSBounds windowBounds = MapControlBounds; IList<IMapOverlay> addedOverlays = new List<IMapOverlay>(); //RouteOverlay //Only add a route exactly once, prefer marked routes IDictionary<IList<IGPSPoint>, MapPolyline> allRoutes = new Dictionary<IList<IGPSPoint>, MapPolyline>(); IDictionary<IList<IGPSPoint>, MapPolyline> dupRoutes = new Dictionary<IList<IGPSPoint>, MapPolyline>(); foreach (KeyValuePair<string, MapPolyline> pair in m_MarkedTrailRoutes) { if (!allRoutes.ContainsKey(pair.Value.Locations)) { allRoutes.Add(new KeyValuePair<IList<IGPSPoint>, MapPolyline>(pair.Value.Locations,pair.Value)); } } foreach (KeyValuePair<string, MapPolyline> pair in m_TrailRoutes) { if (!allRoutes.ContainsKey(pair.Value.Locations)) { allRoutes.Add(new KeyValuePair<IList<IGPSPoint>, MapPolyline>(pair.Value.Locations,pair.Value)); } else if (!dupRoutes.ContainsKey(pair.Value.Locations)) { dupRoutes.Add(new KeyValuePair<IList<IGPSPoint>, MapPolyline>(pair.Value.Locations, pair.Value)); } } IDictionary<IList<IGPSPoint>, MapPolyline> visibleRoutes = new Dictionary<IList<IGPSPoint>, MapPolyline>(); foreach (KeyValuePair<IList<IGPSPoint>, MapPolyline> pair in allRoutes) { IList<IGPSPoint> r = new List<IGPSPoint>(); foreach (IGPSPoint point in pair.Value.Locations) { if (windowBounds.Contains(point)) { visibleRoutes.Add(pair); break; } } //check for route in bounds only - the following does not seem to speed up //foreach (IGPSPoint point in pair.Value.Locations) //{ // if (windowBounds.Contains(point)) // { // r.Add(point); // } //} //if (r.Count > 0) //{ // MapPolyline m = new MapPolyline(r, pair.Value.LineWidth, pair.Value.LineColor); // visibleRoutes.Add(pair.Key, m); //} } IDictionary<IList<IGPSPoint>, IMapOverlay> newRouteOverlays = new Dictionary<IList<IGPSPoint>, IMapOverlay>(); foreach (KeyValuePair<IList<IGPSPoint>, MapPolyline> pair in visibleRoutes) { MapPolyline m = pair.Value; newRouteOverlays.Add(m.Locations, m); if ((!m_scalingChanged) && m_routeOverlays.ContainsKey(m.Locations) && !dupRoutes.ContainsKey(m.Locations)) { //No need to refresh this point m_routeOverlays.Remove(m.Locations); } else { addedOverlays.Add(m); } } //TrailPoints IList<IGPSPoint> visibleLocations = new List<IGPSPoint>(); foreach (TrailGPSLocation point in m_TrailPoints) { if (windowBounds.Contains(point.GpsLocation)) { visibleLocations.Add(Utils.GPS.LocationToPoint(point.GpsLocation)); } } IDictionary<IGPSPoint, IMapOverlay> newPointOverlays = new Dictionary<IGPSPoint, IMapOverlay>(); if (m_scalingChanged || null == m_icon) { m_icon = getCircle(this.MapControl, m_highlightRadius); } foreach (IGPSPoint location in visibleLocations) { if ((!m_scalingChanged) && m_pointOverlays.ContainsKey(location)) { //No need to refresh this point newPointOverlays.Add(location, m_pointOverlays[location]); m_pointOverlays.Remove(location); } else { MapMarker pointOverlay = new MapMarker(location, m_icon, false); newPointOverlays.Add(location, pointOverlay); addedOverlays.Add(pointOverlay); } } // Draw overlay if (0 == visibleLocations.Count && 0 == visibleRoutes.Count) return; m_scalingChanged = false; ClearOverlays(); MapControl.AddOverlays(addedOverlays); m_pointOverlays = newPointOverlays; m_routeOverlays = newRouteOverlays; if (m_extraMapLayer != null) { try { //Remove overlays are not working properly, the Map is not very usable m_extraMapLayer.MapControl.AddOverlays(addedOverlays); }catch(Exception){} m_extraMapLayer.m_pointOverlays = newPointOverlays; m_extraMapLayer.m_routeOverlays = newRouteOverlays; } }