Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc @html.EditorFor(空间数据)_Asp.net Mvc_Spatial_Geography - Fatal编程技术网

Asp.net mvc @html.EditorFor(空间数据)

Asp.net mvc @html.EditorFor(空间数据),asp.net-mvc,spatial,geography,Asp.net Mvc,Spatial,Geography,我是MVC的新手,所以这可能是一个简单的答案,但是,由于没有其他数据类型像这样工作,我在Google上找不到任何东西 我有一个模型,它有一个dbgeography类型的字段。当我使用@Html.EditiorFor()帮助程序时,它添加了十几个不同的字段。我的目标是只询问用户纬度和经度,并使用静态坐标SystemId 4326。其他字段都与我的用户将要创建的地理对象无关 我的模型是 namespace MM.Models { using System; using System.

我是MVC的新手,所以这可能是一个简单的答案,但是,由于没有其他数据类型像这样工作,我在Google上找不到任何东西

我有一个模型,它有一个dbgeography类型的字段。当我使用@Html.EditiorFor()帮助程序时,它添加了十几个不同的字段。我的目标是只询问用户纬度和经度,并使用静态坐标SystemId 4326。其他字段都与我的用户将要创建的地理对象无关

我的模型是

namespace MM.Models
{
    using System;
    using System.Collections.Generic;

    public partial class Projects
    {
        public int ProjectID { get; set; }
        public System.Data.Entity.Spatial.DbGeography BeginPosition { get; set; }
        public System.Data.Entity.Spatial.DbGeography EndPosition { get; set; }
    }
}
我的观点(只是搭建的)如下所示:

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Projects</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ProjectID)
        <div class="form-group">
            @Html.LabelFor(model => model.BeginPosition, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.BeginPosition, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.BeginPosition, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.EndPosition, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.EndPosition, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.EndPosition, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}
@使用(Html.BeginForm())
{
@Html.AntiForgeryToken()
项目

@Html.ValidationSummary(true,“,new{@class=“text danger”}) @Html.HiddenFor(model=>model.ProjectID) @LabelFor(model=>model.BeginPosition,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.BeginPosition,new{htmlAttributes=new{@class=“form control”}}) @Html.ValidationMessageFor(model=>model.BeginPosition,“,new{@class=“text danger”}) @LabelFor(model=>model.EndPosition,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.EndPosition,new{htmlAttributes=new{@class=“form control”}}) @Html.ValidationMessageFor(model=>model.EndPosition,“,new{@class=“text danger”}) }
结果是:


任何帮助都将不胜感激。

只需使用lat/long创建您自己的分部,并添加
[UIHint]
属性。不要使用实体模型作为视图模型。使用EditorTemplate而不是partial