小编Ass*_*Our的帖子

谷歌地图无法读取未定义的属性“地图”

我试图根据用户位置显示标记,但我不断收到此错误,因为我没有找到任何与我的问题匹配的解决方案,我得到的错误是:未捕获的类型错误:无法读取未定义的属性“地图”&它指的是 :at Array.filter (native) 。谢谢:

  <script src="https://maps.googleapis.com/maps/api/js?key="My_Api_Key"&libraries=geometry"></script>
<script>
    "use strict";
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(
            function(position) {

                var markers = @Html.Raw(Json.Encode(Model.UpcomingLectureGigs));
                var currentLatitude = position.coords.latitude;
                var currentLongitude = position.coords.longitude;
                var userLatLng = currentLatitude + currentLongitude;
                var markersFiltered = markers.filter(function(markers, index, array, google) {
                var myLatlng = new window.google.maps.LatLng(markers.Latitude, markers.Longitude);

                    return google.maps.geometry.spherical.computeDistanceBetween(userLatLng, myLatlng) < 10000;
                });
                window.onload = function(a) {
                    var mapOptions = {
                        center: new window.google.maps.LatLng(markers[0].Latitude, markers[0].Longitude),

                        zoom: 8,
                        mapTypeId: window.google.maps.MapTypeId.ROADMAP
                    };

                    var infoWindow = new window.google.maps.InfoWindow();
                    var map = new …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net-mvc google-maps geolocation google-maps-api-3

6
推荐指数
1
解决办法
1万
查看次数

在ASP.NET Core 2中获取用户ID

我正在尝试在ASP.NET Core 2.1 MVC项目中获取用户ID.

但是,我只能收到电子邮件.我几乎肯定必须有1/2行的方式来获取它(在ASP.NET MVC成员中它只是var loggedInUserId = User.Identity.GetUserId();

我到目前为止尝试过这样:

 var loggedInUserId = User.Identity.ToString();    // Result = Name (E-mail) 
 //  var loggedInUserId = User.Identity.Name;    // Result (E-mail)
Run Code Online (Sandbox Code Playgroud)

现在这就是我需要的

asp.net-mvc asp.net-core-2.1

4
推荐指数
1
解决办法
5156
查看次数

无法在剃刀视图中获取枚举显示名称属性

我有一个带有 Display(Name=) 的枚举,我希望在 Razor 视图中显示它,但我只得到了值。

 public enum Gender
 {
    [Display(Name = "Man woman")]
    EveryOne = 0,
    [Display(Name = "Man")]
    Man = 1,
    [Display(Name = "Woman")]
    Woman = 2
 }
Run Code Online (Sandbox Code Playgroud)

剃刀:

 Is for: @Model.LectureGig.Gender
Run Code Online (Sandbox Code Playgroud)

Html 结果是:

适用于:所有人

代替:

适用于: 男人 女人

c# asp.net-mvc enums razor

2
推荐指数
1
解决办法
9430
查看次数