Ejemplo n.º 1
0
        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);
        }
 public static object AddHandler(MapPushpin pushpin, string eventName, IPrimitiveChangedEventHandler handler)
 {
     return(null);
 }
Ejemplo n.º 3
0
        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);
                }
            });
        }
 public static object AddHandler(MapPushpin pushpin, string eventName, MapMouseEventHandler handler)
 {
     return(null);
 }