/** * Add primary layer to the map. */ private void AddPrimaryLayer() { var primary = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), Primary.BASE_LAYER_ID, Primary.ZOOM_LEVEL, Primary.FILTER, Primary.FUNCTION_LINE_COLOR, Primary.FUNCTION_LINE_WIDTH, Primary.FUNCTION_LINE_OFFSET ); var primaryCase = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), Primary.CASE_LAYER_ID, Primary.ZOOM_LEVEL, Primary.FILTER, Primary.FUNCTION_LINE_COLOR_CASE, Primary.FUNCTION_LINE_WIDTH_CASE, Primary.FUNCTION_LINE_OFFSET, Primary.FUNCTION_LINE_OPACITY_CASE ); AddTrafficLayersToMap(primaryCase, primary, GetLastAddedLayerId()); }
/** * Add local layer to the map. */ private void AddLocalLayer() { var local = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), Local.BASE_LAYER_ID, Local.ZOOM_LEVEL, Local.FILTER, Local.FUNCTION_LINE_COLOR, Local.FUNCTION_LINE_WIDTH, Local.FUNCTION_LINE_OFFSET ); var localCase = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), Local.CASE_LAYER_ID, Local.ZOOM_LEVEL, Local.FILTER, Local.FUNCTION_LINE_COLOR_CASE, Local.FUNCTION_LINE_WIDTH_CASE, Local.FUNCTION_LINE_OFFSET, Local.FUNCTION_LINE_OPACITY_CASE ); AddTrafficLayersToMap(localCase, local, PlaceLayerBelow()); }
/** * Add motorway layer to the map. */ private void AddMotorwayLayer() { var motorWay = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), MotorWay.BASE_LAYER_ID, MotorWay.ZOOM_LEVEL, MotorWay.FILTER, MotorWay.FUNCTION_LINE_COLOR, MotorWay.FUNCTION_LINE_WIDTH, MotorWay.FUNCTION_LINE_OFFSET ); var motorwayCase = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), MotorWay.CASE_LAYER_ID, MotorWay.ZOOM_LEVEL, MotorWay.FILTER, MotorWay.FUNCTION_LINE_COLOR_CASE, MotorWay.FUNCTION_LINE_WIDTH_CASE, MotorWay.FUNCTION_LINE_OFFSET ); AddTrafficLayersToMap(motorwayCase, motorWay, GetLastAddedLayerId()); }
/** * Add trunk layer to the map. */ private void AddTrunkLayer() { var trunk = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), Trunk.BASE_LAYER_ID, Trunk.ZOOM_LEVEL, Trunk.FILTER, Trunk.FUNCTION_LINE_COLOR, Trunk.FUNCTION_LINE_WIDTH, Trunk.FUNCTION_LINE_OFFSET ); var trunkCase = TrafficLayer.GetLineLayer( style.SourceWithIdentifier(TrafficData.SOURCE_ID), Trunk.CASE_LAYER_ID, Trunk.ZOOM_LEVEL, Trunk.FILTER, Trunk.FUNCTION_LINE_COLOR_CASE, Trunk.FUNCTION_LINE_WIDTH_CASE, Trunk.FUNCTION_LINE_OFFSET ); AddTrafficLayersToMap(trunkCase, trunk, GetLastAddedLayerId()); }
public void Run() { Element rootElement = Document.GetElementById("map"); MapOptions mapOptions = new MapOptions(); mapOptions.Credentials = (string)rootElement.GetAttribute("data-credentials"); mapOptions.Width = 640; mapOptions.Height = 480; mapOptions.ShowCopyright = false; mapOptions.ShowMapTypeSelector = false; mapOptions.ShowLogo = false; mapOptions.ShowScalebar = false; mapOptions.ShowNavControl = false; mapOptions.ShowDashboard = false; mapOptions.Center = new MapLocation(47.610377, -122.2006786); mapOptions.Zoom = 10; mapOptions.MapType = MapType.Road; MapPushpinOptions pushpinOptions = new MapPushpinOptions(); _pushpin = new MapPushpin(mapOptions.Center, pushpinOptions); MapInfoboxOptions infoboxOptions = new MapInfoboxOptions(); infoboxOptions.Title = "Bellevue"; infoboxOptions.Visible = false; infoboxOptions.Offset = new MapPoint(0, 20); infoboxOptions.Height = 48; infoboxOptions.Width = 80; infoboxOptions.ShowCloseButton = false; _infobox = new MapInfobox(mapOptions.Center, infoboxOptions); _map = new Map(rootElement, mapOptions); _map.Entities.Push(_pushpin); _map.Entities.Push(_infobox); MapEvents.AddHandler(_pushpin, "click", OnPushpinClick); MapEvents.AddHandler(_map, "viewchange", OnViewChanged); MapModuleOptions trafficOptions = new MapModuleOptions(); trafficOptions.Callback = delegate() { TrafficLayer trafficLayer = new TrafficLayer(_map); trafficLayer.Show(); }; Map.LoadModule(MapModule.Traffic, trafficOptions); MapModuleOptions venueMapOptions = new MapModuleOptions(); venueMapOptions.Callback = delegate() { VenueMapFactory venueMapFactory = new VenueMapFactory(_map); VenueMapSearchOptions searchOptions = new VenueMapSearchOptions(); searchOptions.Map = _map; searchOptions.Location = mapOptions.Center; searchOptions.Radius = 1000; searchOptions.Callback = delegate(Venue[] venues) { if (venues.Length != 0) { VenueMapOptions venueOptions = new VenueMapOptions(); venueOptions.VenueMapID = venues[0].Metadata.ID; venueOptions.SuccessCallback = delegate(VenueMap venueMap, VenueMapOptions options) { venueMap.Show(); if (Window.Confirm("Zoom to " + venueMap.Name + "?")) { _map.SetView(venueMap.BestMapView); } }; venueMapFactory.Create(venueOptions); } }; venueMapFactory.Search(searchOptions); }; Map.LoadModule(MapModule.VenueMaps, venueMapOptions); Element locateMeButton = Document.GetElementById("locateMeButton"); locateMeButton.AddEventListener("click", OnLocateMeClick, false); }