Asp.net mvc 5 MVC5 Bing地图示例

Asp.net mvc 5 MVC5 Bing地图示例,asp.net-mvc-5,bing-maps,Asp.net Mvc 5,Bing Maps,我一直试图让GMap3在MVC5框架上工作,但没有成功,开发者网站也没有回应。所以,我决定试试虚拟地球,也就是Bing地图 然而,这也不起作用,我得到了一张空地图。我所发现的只是对旧API的引用和不起作用的东西 基本上我在头部有这个元素 <script type="text/javascript" src="http://ecn.dev.virtualearth.net/MapControl/mapcontrol.ashx?v=6.3c"> </script>

我一直试图让GMap3在MVC5框架上工作,但没有成功,开发者网站也没有回应。所以,我决定试试虚拟地球,也就是Bing地图

然而,这也不起作用,我得到了一张空地图。我所发现的只是对旧API的引用和不起作用的东西

基本上我在头部有这个元素

<script type="text/javascript" src="http://ecn.dev.virtualearth.net/MapControl/mapcontrol.ashx?v=6.3c">
    </script>

在视图的主体中

<div id="mymapcontroldiv" style="width:500px;height:500px;position:relative;border:1px;border-color:brown;background-color: #E0E0E0;"></div>


<script>
$(document).ready(function () {
    var map = new VEMap("mymapcontroldiv");
    var center = new VELatLong(@Model.Latitude,  @Model.Longitude);
    var zoom = 12;
    map.LoadMap(center, zoom, VEMapStyle.Road, false);

    // var pinpoint = map.GetCenter();
    var pushpin = new VEPushPin('1', center, null, 'Panama','ImexCorp S.A.');
    map.AddPushpin(pushpin);

    alert("xx");
    addMarker(@Model.Latitude, @Model.Longitude, @Model.LocationName, 'description');
});



</script>

<script type="text/javascript">


  //declare addMarker function
function addMarker(latitude, longitude, title, description)
{
    var marker = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(latitude, longitude), { icon: "/Content/img/poi_custom.png" });
    map.entities.push(marker);
};

alert("xx");
addMarker(@Model.Latitude, @Model.Longitude, @Model.LocationName, 'description');

</script>

$(文档).ready(函数(){
var map=新的VEMap(“mymapcontroldiv”);
var中心=新VELatLong(@Model.Latitude,@Model.Longitude);
var=12;
map.LoadMap(居中、缩放、VEMapStyle.Road、假);
//var pinpoint=map.GetCenter();
var图钉=新的VEPushPin('1',中间,空,'Panama','ImexCorp S.A.);
地图。添加图钉(图钉);
警报(“xx”);
addMarker(@Model.Latitude,@Model.Longitude,@Model.LocationName,'description');
});
//声明addMarker函数
函数addMarker(纬度、经度、标题、描述)
{
var marker=new Microsoft.Maps.Pushpin(新的Microsoft.Maps.Location(纬度、经度),{icon:“/Content/img/poi_custom.png”});
地图。实体。推(标记);
};
警报(“xx”);
addMarker(@Model.Latitude,@Model.Longitude,@Model.LocationName,'description');

我对脚本进行的alert()调用似乎从未出现过。我只能从div样式中看到地图背景,没有其他内容。

尝试将addMarker函数的内容放入document ready中(不要调用此函数,只需将其内容放入document ready中,然后删除其他部分即可)。如果它能工作,那么它更多的是一个JavaScript问题,而不是Bing的问题。如果删除底部的块,则应加载贴图。此外,考虑移动到V7:看来V7需要一个API密钥,它没有绑定到任何东西,它是可兑现的,微软不提供其他人使用你的密钥的保护。我不认为这是我想走的路。