定位获取地址coffee语法

来源:互联网 发布:我的世界瞳术js视频 编辑:程序博客网 时间:2024/05/22 06:19

 #定位地图    self.locationAdd =(city) ->        dialogData = {            action: "",            cityName:city        }        dialogData.dialog = ngDialog.open({            template: 'templates/line-trouble/info/location-dialog.html'            className: 'ngdialog-theme-plain custom-width-70per'            scope: $scope            data: dialogData            controller: 'GetLocationController'            controllerAs: 'controller'        })        dialogData.dialog.closePromise.then((data) ->            if dialogData.action && dialogData.action == "confirm" && dialogData.data                #self.selectedGrid = dialogData.data                $scope.entity.positionAdd = dialogData.data        )

angular.module "application".controller "GetLocationController", ($scope, $rootScope, $state, $stateParams, httpExecutor, userService, NgTableParams, areaService, ngDialog)->    self = @    self.ngDialogData = $scope.ngDialogData    self.map = {}# 从服务端获取地图数据    self.getAllMapData = ->        httpExecutor.execute('api/basis/stationLocation/list', {            page: 0,            size: 10000        }).then (response)->            self.mapData = response.content         # self.mapData 为数组            self.renderMap()# 设置一个定时器来获取地图的 DOM, 并生成地图    mapContainerListener = setInterval(()->        if document.getElementById("bmap_container")            clearInterval(mapContainerListener)            self.getAllMapData()    , 1000)    lnglatXY = [];    self.map.address =""    self.renderMap = ->        self.map.mapObj = new AMap.Map('bmap_container',{resizeEnable: true,zoom:12})        # 控件        cityName =self.ngDialogData.cityName        if !cityName            showCityInfo = ->                citysearch = new AMap.CitySearch()                citysearch.getLocalCity((status,result)->                    if status == 'complete' && result.info == 'OK'                        if result && result.city && result.bounds                            cityinfo = result.city                            citybounds = result.bounds                            self.map.mapObj.setBounds(citybounds)                )        self.map.marker = new AMap.Marker({            map: self.map.mapObj,            title:cityName,            offset: new AMap.Pixel(-17, -42),            draggable: true        })        clickEventListener = self.map.marker.on('click',(e)->            document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat()            lnglatXY = [e.lnglat.getLng(),e.lnglat.getLat()]            self.getGeocoder(lnglatXY)        )        self.geocoder        AMap.plugin(['AMap.ToolBar','AMap.Scale','AMap.OverView','AMap.Geocoder'],()->            self.map.mapObj.addControl(new AMap.ToolBar())            self.map.mapObj.addControl(new AMap.Scale())            self.map.mapObj.addControl(new AMap.ToolBar({locationMarker: self.map.marker}))            self.geocoder = new AMap.Geocoder({                radius: 1000,                extensions: "all"            })        )        self.getGeocoder =(lnglatXY)->            self.geocoder.getAddress(lnglatXY,(status, result)->                if status == 'complete' && result.info == 'OK'                    geocoder_CallBack(result)            )            geocoder_CallBack =(data)->                address = data.regeocode.formattedAddress                document.getElementById("result").innerHTML = address                self.map.address = address        self.map.mapObj.setCity(cityName)        self.map.mapObj.setFitView()    self.confirm = ->        $scope.ngDialogData.action = "confirm"        $scope.ngDialogData.data = self.map.address        # 关闭当前的 ngdialog        $scope.closeThisDialog()






0 0
原创粉丝点击