如何在dragend之后获得ng-map标记位置?

时间:2016-02-14 17:08:27

标签: javascript angularjs google-maps-api-3 ng-map

我正在使用ng-map for Angularjs,我使用以下代码在拖动事件后获取标记位置

public class SomeController : ApiController
    {
        public string First()
        {
            OAuth2Parameters parameters = new OAuth2Parameters();

            parameters.ClientId = "someClientID";
            parameters.ClientSecret = "someClientSecret";
            parameters.RedirectUri = "someRedirectUri";
            parameters.Scope = "someScope";

            string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);

            return authorizationUrl;
        }

        public void Second(string someAccessCode)
        {
            // I want to reuse the above OAuth2Parameters parameters here:
            parameters.AccessCode = someAccessCode;

            OAuthUtil.GetAccessToken(parameters);
            string accessToken = parameters.AccessToken;
        }
    }

<div class="mapWrap"   data-tap-disabled="true">

        <map center="43.07493,-89.381388" zoom="4"> 

          <marker draggable=true position="{{pos.lat}},{{pos.lng}}" 
          on-dragend="getCurrentLocation()"></marker>    
        </map>

但它不起作用。有什么建议吗?

1 个答案:

答案 0 :(得分:3)

从on-dragend事件中得到它:

$scope.getCurrentlocation = function(e) {
    $scope.address.lat = e.latLng.lat();
    $scope.address.lng = e.latLng.lng();
};

至少这对我有用。