Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.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
C# Visual Studio Visual Studio MVC asp.NET谷歌地图_C#_Asp.net_Asp.net Mvc_Visual Studio_Google Maps - Fatal编程技术网

C# Visual Studio Visual Studio MVC asp.NET谷歌地图

C# Visual Studio Visual Studio MVC asp.NET谷歌地图,c#,asp.net,asp.net-mvc,visual-studio,google-maps,C#,Asp.net,Asp.net Mvc,Visual Studio,Google Maps,如何在我创建的地图上显示标记.Marker(“1.2233424,4.865876)对我不起作用 @using Jmelosegui.Mvc.GoogleMap <div class="row"> <div class="col-md-12"> @(Html.GoogleMap() .Name("map") .Height(400) .Width(700)

如何在我创建的地图上显示标记
.Marker(“1.2233424,4.865876)
对我不起作用

@using Jmelosegui.Mvc.GoogleMap
<div class="row">
     <div class="col-md-12">
          @(Html.GoogleMap()
             .Name("map")
             .Height(400)
             .Width(700)
           )
     </div>
</div>
@使用Jmelosegui.Mvc.GoogleMap
@(Html.GoogleMap()
.名称(“地图”)
.身高(400)
.宽度(700)
)

您的语法错误。您需要使用

.Markers(m=>m.Add().Title(“Hello World!”)


查看了解更多信息

您需要添加
.Center(c=>c.纬度(1.2233424).经度(4.865876))


来源:

为了在同一地图上获得多个标记,您需要使用bounds方法。此示例使用javascript

Html


map.fitBounds(bounds)将在您的标记之间将地图居中,这样所有标记都将显示在屏幕上。

非常感谢,如果我想添加多个标记来显示欧洲的城市,我该如何实现这一点?您可以继续添加标记。标记(m=>m.add().Title(“long”,“lat”))。标记(m=>m.add().Title(“long1”,“lat1”)).Markers(m=>m.Add().Title(“long3”,“lat3”))那么我可以继续添加几个这样的标记吗?非常感谢,如果我想添加多个标记来展示欧洲的城市,我该如何实现这一点?非常感谢:)
Html.GoogleMap()
            .Name("map")
            .Height(300)
            .Center(c => c.Latitude(1.2233424)
                          .Longitude(4.865876))
            .Markers(m => m.Add().Title("Hello World!"))
<div itemprop="map" id="googleMap" style="height:400px;width:100%;"></div>


                <script src="https://maps.googleapis.com/maps/api/js"></script>
var myCenter = new google.maps.LatLng(YourLat, YourLng);
var myCenter2 = new google.maps.LatLng(YourSecondLat, YourSecondLng);

function initialize() {
    var bounds = new google.maps.LatLngBounds(myCenter, myCenter2);
    var mapProp = {
        zoom: 12,
        scrollwheel: false,
        draggable: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);

    var marker = new google.maps.Marker({
        position: myCenter,
        map: map,
    });
    var marker2 = new google.maps.Marker({
        position: myCenter2,
        map: map,
    })
    map.fitBounds(bounds);
}

google.maps.event.addDomListener(window, 'load', initialize);