private AMapCircle m_circle;//圆

        public NearbyStatsPage()
        {
            InitializeComponent();

            m_amap = new AMap();
            m_amap.MarkerClickListener += amap_MarkerClickListener;
            this.ContentPanel.Children.Add(m_amap);
        }
Example #2
0
        /// <summary>
        /// Application 对象的构造函数。
        /// </summary>
        public App()
        {
            IsFromSearchPage = false;
            IsFromRoutePage = false;
            TempMap = null;
            _latlng = null;
            _bearing = 0;
            _tile = 0;
            _cameraIsNew = true;
            _isNew = true;
            SocketClient=new SocketClient();

            // 未捕获的异常的全局处理程序。
            UnhandledException += Application_UnhandledException;

            // 标准 XAML 初始化
            InitializeComponent();

            // 特定于电话的初始化
            InitializePhoneApplication();

            // 语言显示初始化
            InitializeLanguage();

            /*******************************************
               填写高德地图服务key
               *******************************************/
            const string key = "a1b63541add32fada5840b302d2325f8";

            AMapConfig.Key = key;//地图显示key
            AMapSearchConfig.Key = key;

            // 调试时显示图形分析信息。
            if (Debugger.IsAttached)
            {
                // 显示当前帧速率计数器。
                Current.Host.Settings.EnableFrameRateCounter = true;

                // 显示在每个帧中重绘的应用程序区域。
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // 启用非生产分析可视化模式,
                // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // 通过禁用以下对象阻止在调试过程中关闭屏幕
                // 应用程序的空闲检测。
                //  注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行
                // 并且消耗电池电量。
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
            SetUriMapping();
        }
Example #3
0
        private bool _isNew;//屏蔽大北京
        // 构造函数
        public MainPage()
        {
            
            InitializeComponent();
            /******变量初始化*****/
            _zoomIsNew = true;
            _cameraIsNew = true;
            _isNew = true; 
            isExit = false;
            _client = (Application.Current as App).SocketClient;
            /******变量初始化*****/

            

            _amap = (Application.Current as App).TempMap;
            if (_amap == null)
            {
                _amap=new AMap();//新建地图
            }
            if (_amap != null)
            {
                ContentPanel.Children.Add(_amap); //加载地图
                //恢复地图相关参数
                #region
                _latlng = (Application.Current as App)._latlng;
                _bearing = (Application.Current as App)._bearing;
                _tile = (Application.Current as App)._tile;
                _circle = (Application.Current as App)._circle;
                _locationMarker = (Application.Current as App)._locationMarker;
                _cameraLatlng = (Application.Current as App)._CameraLatLng;
                _mapZoom = (Application.Current as App)._mapZoom;
                _cameraIsNew = (Application.Current as App)._cameraIsNew;
                _isNew = (Application.Current as App)._isNew;
                #endregion

                DoubleTabToExit(2);//按两次退出键退出程序

                //异步连接服务器,增加程序友好性
                Dispatcher.BeginInvoke(() =>
                {
                    Debug.WriteLine("连接服务器");
                    ConnectServer(_client);
                }
                    );

            }

            var uiset = _amap.GetUiSettings();
            uiset.CompassControlEnabled = false; //将原有指南针设置为不显示
            uiset.ZoomControlsEnabled = false; //将原有缩放控件设置为不显示
            MakerTextBlock.Visibility = Visibility.Collapsed;//设置标记信息文本框不可见
            MakertextblockbgGrid.Visibility = Visibility.Collapsed;//设置标记信息文本框背景不可见
            BuildLocalizedApplicationBar();// 用于本地化 ApplicationBar 的示例代码
            //ApplicationBar.IsVisible = false;

            _amap.CameraChangeListener += amap_CameraChangeListener; //视角移动函数(指南针使用)
            _amap.Tap += amap_Tap;//添加地图单击事件函数
            _amap.Hold += amap_hold;//添加地图长按事件函数   
            Loaded += Mylocation_Loaded;
            Unloaded += Mylocation_Unloaded;
            

        }
Example #4
0
    void Start()
    {
        map = new int[, ] {
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
            { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
            { 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1 },
            { 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1 },
            { 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1 },
            { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1 },
            { 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 },
            { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1 },
            { 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1 },
            { 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1 },
            { 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 },
            { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
            { 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
            { 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
            { 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1 },
            { 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 },
            { 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1 },
            { 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 },
            { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
        };

        if (map[startRow, startCol] == 1)
        {
            Debug.Log("Error:起点不能是墙!!!");
            return;
        }

        if (map[endRow, endCol] == 1)
        {
            Debug.Log("Error:终点不能是墙!!!");
        }

        if (startRow < 0 || startRow >= map.GetLength(0) || startCol < 0 || startCol >= map.GetLength(1) ||
            endRow < 0 || endRow >= map.GetLength(0) || endCol < 0 || endCol >= map.GetLength(1))
        {
            Debug.Log("Error:非法的索引值!!!");
            return;
        }

        AMap           myMap = new AMap(map);
        AStarAlgorithm gbpa  = new AStarAlgorithm(myMap);

        gbpa.Start(myMap.aNodes[GetIndex(startRow, startCol, map)], myMap.aNodes[GetIndex(endRow, endCol, map)]);
        Stack <ANode> path = gbpa.Find();

        ResetMapColor(myMap);

        if (path != null)
        {
            Debug.Log("Serach one path!");
            while (path.Count != 0)
            {
                ANode node = path.Pop();

                imgaes[GetIndex(node.Row, node.Col, map)].color = Color.blue;
            }
        }
        else
        {
            Debug.Log("Some Errors!!!");
        }
    }
Example #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            startLatlng = new LatLng(Intent.GetDoubleExtra("StartLatitude", 0), Intent.GetDoubleExtra("StartLongitude", 0));
            isLine      = Intent.GetBooleanExtra("isLine", false);
            if (isLine)
            {
                endLatlng = new LatLng(Intent.GetDoubleExtra("EndLatitude", 0), Intent.GetDoubleExtra("EndLongitude", 0));
            }
            SetContentView(Resource.Layout.amap_layout);
            //SetSupportActionBar(new Android.Support.V7.Widget.Toolbar(this));
            var actionBar = SupportActionBar;

            if (actionBar != null)
            {
                actionBar.SetHomeButtonEnabled(true);
                actionBar.SetDisplayHomeAsUpEnabled(true);
            }

            mapView = FindViewById <MapView>(Resource.Id.map);

            //AMapOptions options = new AMapOptions();
            //options.InvokeCamera(new CameraPosition(latlng, 15,  0, 0));
            //mapView = new MapView(this, options);
            mapView.OnCreate(savedInstanceState);

            if (aMap == null)
            {
                aMap = mapView.Map;
                //设置marker
                markerOption = new MarkerOptions().InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed))
                               .InvokeTitle("施封位置").InvokeSnippet(Intent.GetStringExtra("startAddress")).InvokePosition(startLatlng).Draggable(true);
                aMap.AddMarker(markerOption).ShowInfoWindow();
                if (isLine)
                {
                    //设置中心点
                    var update = CameraUpdateFactory.NewCameraPosition(new CameraPosition(endLatlng, 5, 0, 0));
                    aMap.MoveCamera(update);
                    //设置marker
                    MarkerOptions endMarkerOption = new MarkerOptions().InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen))
                                                    .InvokeTitle("拆封位置").InvokeSnippet(Intent.GetStringExtra("endAddress")).InvokePosition(endLatlng).Draggable(true);
                    aMap.AddMarker(endMarkerOption).ShowInfoWindow();
                    PolylineOptions polylineOptions = new PolylineOptions();
                    var             laglngs         = new ArrayList();
                    laglngs.Add(startLatlng);
                    laglngs.Add(endLatlng);
                    polylineOptions.AddAll(laglngs);
                    polylineOptions.InvokeWidth(10);
                    polylineOptions.InvokeColor(Color.Argb(255, 0, 205, 205));
                    polylineOptions.Visible(true);
                    var polyline = aMap.AddPolyline(polylineOptions);
                    polyline.Visible = true;
                    var endupdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition(endLatlng, 10, 0, 0));
                    aMap.MoveCamera(update);
                }
                else
                {
                    //设置中心点
                    var update = CameraUpdateFactory.NewCameraPosition(new CameraPosition(startLatlng, 15, 0, 0));
                    aMap.MoveCamera(update);
                }
            }
        }
 public MapMarkerPage()
 {
     InitializeComponent();
     this.ContentPanel.Children.Add(amap = new AMap());
     this.btnVisible.IsEnabled           = false;
 }