在Lightswitch中使用Javascript配置一个地图控件

Configuring a map control using Javascript in Lightswitch

本文关键字:一个 控件 地图 配置 Lightswitch Javascript      更新时间:2023-09-26

我一直在尝试将Bing地图放入我的Lightswitch visual studio项目中,并在互联网上找到了一些我已经适应我自己数据的代码。然而,我可以让地图加载,但它似乎并没有采取我的数据,只是显示了一个随机点在海洋中间,而不是我输入的位置!

这是我找到并改编的代码:

function rebindMap(element, contentItem) {
// Verify that we aren't updating the map continuously due to multiple bound values changing.
var now = new Date();
if (now.getTime() - mapLastUpdated.getTime() > 15) {
    setTimeout(function () {
        updateMap(element, contentItem);
        mapLastUpdated = new Date();
    }, 20);
}
};
function updateMap(element, contentItem) {
var mapDiv = $("#appointmentMap");
// If we've previously created the map, make sure to clean up the div that contained it;
// otherwise, the Bing map control fails to create properly.
if (mapDiv.length > 0) {
    $(mapDiv).remove();
}
mapDiv = $("<div id='appointmentMap' class='msls-hauto msls-vauto' ></div>");
$(mapDiv).appendTo($(element));
mapControl = mapDiv.lightswitchBingMapsControl({
    country: contentItem.value.Spatial_Data,
    state: contentItem.value.State_Province,
    postalcode: contentItem.value.Postal_Code,
    address: contentItem.value.Address,
    city: contentItem.value.City,
    latitude: contentItem.value.Latitude,
    longitude: contentItem.value.Longitude,
    mapTypeId: Microsoft.Maps.MapTypeId.road,

    height: "400"
});
};

myapp.View_Retail.Site_Name1_render = function (element, contentItem) {
    // Write code here.
    updateMap(element, contentItem);
    mapLastUpdated = new Date();
    contentItem.dataBind("value.country", function () { rebindMap(element, contentItem); });
    contentItem.dataBind("value.state", function () { rebindMap(element, contentItem); });
    contentItem.dataBind("value.postalcode", function () { rebindMap(element, contentItem); });
    contentItem.dataBind("value.address", function () { rebindMap(element, contentItem); });
    contentItem.dataBind("value.city", function () { rebindMap(element, contentItem); });
    contentItem.dataBind("value.latitude", function () { rebindMap(element, contentItem); });
    contentItem.dataBind("value.longitude", function () { rebindMap(element, contentItem); });
};

我从微软网站上得到了代码:http://technet.microsoft.com/en-ca/jj674624(v=vs.71).aspx

我不明白我错过了什么!我不是很有经验的javascript,所以任何帮助将非常感激:)

为什么不使用bing地图控件扩展,在表中创建一个地图地址属性,并为它创建一个查询

result = Address1 + ", " + City + ", " + State + ", " + PostalCode;