public void SetOptions(MapPushpinOptions options) { }
public MapPushpin(MapLocation location, MapPushpinOptions options) { }
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 (Script.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); }
private static void UpdatePhotos(bool newPhotos) { if (newPhotos) { if (_mapEntities != null) { _map.Entities.Remove(_mapEntities); } _mapEntities = new MapEntityCollection(); _map.Entities.Push(_mapEntities); _photoViews = new Dictionary<string, PhotoView>(); } if (_model.Photos.Count == 0) { Document.Body.ClassName = MapModeClassName; return; } Document.Body.ClassName = PhotosModeClassName; _graph = new Graph(); _model.Photos.ForEach(delegate(Photo photo) { MapLocation location = new MapLocation(photo.latitude, photo.longitude); MapPoint point = _map.TryLocationToPixel(location, MapPointReference.Control); PhotoView photoView; if (newPhotos) { MapPolylineOptions connectorOptions = new MapPolylineOptions(); connectorOptions.StrokeColor = new MapColor(255, 0x4E, 0xD3, 0x4E); connectorOptions.StrokeThickness = 2; MapInfoboxOptions calloutOptions = new MapInfoboxOptions(); calloutOptions.Width = 50; calloutOptions.Height = 50; calloutOptions.ShowPointer = false; calloutOptions.ShowCloseButton = false; calloutOptions.Offset = new MapPoint(-25, -25); calloutOptions.HtmlContent = "<div class=\"photoInfobox\" style=\"background-image: url(" + photo.thumbnailUrl + ")\"" + " title=\"" + photo.title.HtmlEncode() + "\"></div>"; calloutOptions.Visible = true; MapPushpinOptions pushpinOptions = new MapPushpinOptions(); pushpinOptions.Icon = "Dot.png"; pushpinOptions.Width = 10; pushpinOptions.Height = 10; pushpinOptions.Anchor = new MapPoint(5, 5); pushpinOptions.TypeName = "locationPushpin"; photoView = new PhotoView(); photoView.pushpin = new MapPushpin(location, pushpinOptions); photoView.connector = new MapPolyline(new MapLocation[] { location, location }, connectorOptions); photoView.callout = new MapInfobox(location, calloutOptions); photoView.callout.Data = photo; _photoViews[photo.id] = photoView; _mapEntities.Insert(photoView.connector, 0); _mapEntities.Insert(photoView.callout, 0); _mapEntities.Insert(photoView.pushpin, 0); MapEvents.AddHandler(photoView.callout, "click", delegate(MapEventArgs e) { ShowPhoto(photo); }); } else { photoView = _photoViews[photo.id]; } photoView.pushpinNode = new GraphNode(); photoView.pushpinNode.x = point.X; photoView.pushpinNode.y = point.Y; photoView.pushpinNode.moveable = false; photoView.calloutNode = new GraphNode(); photoView.calloutNode.x = point.X; photoView.calloutNode.y = point.Y; GraphEdge connectorEdge = new GraphEdge(photoView.pushpinNode, photoView.calloutNode, 10 + Math.Random() * 15); _graph.AddNode(photoView.pushpinNode); _graph.AddNode(photoView.calloutNode); _graph.AddEdge(connectorEdge); }); Window.SetTimeout(UpdateLayout, 30); }
private static void ShowLocation() { Window.Navigator.Geolocation.GetCurrentPosition(delegate(Geolocation location) { MapViewOptions viewOptions = new MapViewOptions(); viewOptions.Center = new MapLocation(location.Coordinates.Latitude, location.Coordinates.Longitude); viewOptions.Zoom = 10; viewOptions.Animate = true; _map.SetView(viewOptions); UpdatePhotos(/* newPhotos */ false); if (_currentPushpin == null) { MapPushpinOptions pushpinOptions = new MapPushpinOptions(); pushpinOptions.Icon = "Pushpin.png"; pushpinOptions.Anchor = new MapPoint(12, 14); pushpinOptions.Width = 25; pushpinOptions.Height = 28; pushpinOptions.TypeName = "currentPushpin"; _currentPushpin = new MapPushpin(viewOptions.Center, pushpinOptions); _map.Entities.Push(_currentPushpin); } else { _currentPushpin.SetLocation(viewOptions.Center); } }); }