我有以下代码来添加要映射的位置(此处为API Maps)。但是在map.addObject(group);处遇到错误SCRIPT438: Object doesn't support property or method 'addObject'。我搜索了许多其他解决方案,但没有一个对我有用。这在Mozilla Firefox中完美运行,但在IE 11中不起作用。可能是什么问题?

locations是一个仅包含“ Here Maps Api”中建议位置的数组。

dvList是在地图上绘制点的数组。

function addLocationsToMap(locations) {
$vehPoints = '';
$dvListLength = 0;
var icon = '';
if (locations.length > 0) {
    var group = new H.map.Group();
    var position, i;
    var icon = new H.map.Icon('/Images/Icons/destination1.png');
    // Add a marker for each location found
    for (i = 0; i < locations.length; i += 1) {
        position = {
            lat: locations[i].location.displayPosition.latitude,
            lng: locations[i].location.displayPosition.longitude
        };
        marker = new H.map.Marker(position, { icon: icon });
        marker.label = locations[i].location.address.label;
        group.addObject(marker);
    }
    marker.addEventListener('tap', function (evt) {
        openBubble(evt.target.getPosition(), evt.target.label);
    }, false);

    if ($dvList == null)
        $dvListLength = 0;
    else
        $dvListLength = $dvList.length;
    // Add the locations group to the map
    for (var c = 0; c < $dvListLength; c++) {
        $lat = $dvList[c].LATITUDE;
        $long = $dvList[c].LONGITUDE;
        if ($lat != "" && $long != "" && $lat != undefined && $long != undefined && $lat != null && $long != null) {
            var radlat1 = Math.PI * parseFloat(position.lat) / 180;
            var radlat2 = Math.PI * parseFloat($lat) / 180;
            var radlon1 = Math.PI * parseFloat(position.lng) / 180;
            var radlon2 = Math.PI * parseFloat($long) / 180;
            var theta = parseFloat(position.lng) - parseFloat($long);
            var radtheta = Math.PI * theta / 180;
            distance = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
            distance = Math.acos(distance);
            distance = distance * 180 / Math.PI;
            distance = distance * 60 * 1.1515;
            distance = parseInt(distance * 1.609344);

            if (distance <= 100) {
                if ($('#radDriver').prop("checked")) {
                    icon = new H.map.Icon($dvList[c].DVICON);
                }
                else {
                    icon = new H.map.Icon($dvList[c].VEHICON);
                }
                var marker1 = new H.map.Marker({ lat: parseFloat($lat), lng: parseFloat($long) }, { icon: icon });
                marker1.setData($dvList[c].TOOLTIP);
                group.addObject(marker1);
                marker1.addEventListener('tap', function (evt) {
                    openBubble(evt.target.getPosition(), evt.target.getData());
                }, false);
                //$vehPoints = $vehPoints + $dvList[c].VEHICLEID + ',';
            }
        }
    }
    //end of for loop
        map.addObject(group);
        map.setViewBounds(group.getBounds());
}
else {
    alert('Address not found');
    return false;
}


}

任何帮助,将不胜感激 :)

最佳答案

请使用Maps API for JavaScript 3.1(而不是3.0)。新版本3.1没有此缺陷。
请参见Migration to 3.1Examples

09-20 21:37