| xqd
@@ -1,5 +1,5 @@
|
|
|
(function (app) {
|
|
|
- app.factory('userService', ['$http', 'config', "util",'data', function ($http, config, util,data) {
|
|
|
+ app.factory('userService', ['$http', 'config', "util", 'data', '$q', function ($http, config, util, data, $q) {
|
|
|
return {
|
|
|
login:function (username,password) {
|
|
|
return $http({
|
| xqd
@@ -47,6 +47,29 @@
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
resolve('ok');
|
|
|
});
|
|
|
+ },
|
|
|
+ //获取高德地图图片
|
|
|
+ getMapPic: function (input) {
|
|
|
+ var deferred = $q.defer();
|
|
|
+ var defaultPath = "img/demo/defaultmap.png";
|
|
|
+ if (!input) return defaultPath;
|
|
|
+ var arr = input.split(',');
|
|
|
+ var key = '9f832e163baac0a04d437a52dd3e5d29';
|
|
|
+ var keywords = arr[arr.length - 1];
|
|
|
+ var url = 'http://restapi.amap.com/v3/place/text?key=' + key + '&keywords=' + keywords + "&callback=JSON_CALLBACK";
|
|
|
+ $http.jsonp(url).then(function (result) {
|
|
|
+ var p = result.data.pois[0];
|
|
|
+ if (p) {
|
|
|
+ var l = p.location;
|
|
|
+ var m="http://restapi.amap.com/v3/staticmap?location=" + l + "&zoom=9&size=360*160&markers=mid,,A:" + l + "&key=" + key;
|
|
|
+ deferred.resolve(m);
|
|
|
+ } else {
|
|
|
+ deferred.resolve(defaultPath);
|
|
|
+ }
|
|
|
+ }, function (erro) {
|
|
|
+ deferred.reject(erro);
|
|
|
+ });
|
|
|
+ return deferred.promise;
|
|
|
}
|
|
|
};
|
|
|
}]);
|