1

Mapstraction v1 (mapstraction.js)でOpenlayersを使用していますが、マーカーを登録できません。マーカーは単にイベントに応答しません。機能はここにあります、どんな助けでも大いに感謝されます。

//Add marker manager for specified zoom level
function addmmangerforzoom(zoomlevel) {
try {

    nocache_urladdon = "&nocache=" + new Date().getTime();
    geturl = baseurl + "&t=markerdata&unit=" +  currtrackerunit + "&date=" + currdate + "&zoomlevel=" + zoomlevel + nocache_urladdon;
    var loader = new net.ContentLoader(geturl, function() {
        eval("var jsondata = " + this.req.responseText);

        //Go through lat/lon cords
        var gmarkers = [];
        var i = 0;
        var totalicon = jsondata["data"].length;
        for (var markerarr in jsondata["data"]) {

            //Choose icon
            var icon = chooseicon("archive", i, jsondata["data"][markerarr][3], totalicon);

            //Create point
            var point = new LatLonPoint(jsondata["data"][markerarr][1], jsondata["data"][markerarr][2]);

            //Create marker
            var marker = new Marker(point);

            //Set zoom level to show this marker
            marker.setAttribute("zoomlevel", zoomlevel);

            //Set marker icon
            if (mapstraction.api == "openlayers") {
                //Mapstraction seems to have a bug, openlayers required negative anchor position
                var iconanchor = [
                    -icon["iconanchor"][0],
                    -icon["iconanchor"][1]
                ];
                marker.setIcon(icon["image"], icon["iconsize"], iconanchor);
            } else {
                marker.setIcon(icon["image"], icon["iconsize"], icon["iconanchor"]);
            }

            marker.setShadowIcon(icon["image"], icon["iconsize"]);

            //Add marker to map
            mapstraction.addMarker(marker);

            if (mapstraction.api == "openlayers") {
                marker.proprietary_marker.mid = jsondata["data"][markerarr][0];
                marker.proprietary_marker.Lon = jsondata["data"][markerarr][2];
                marker.proprietary_marker.Lat = jsondata["data"][markerarr][1];
                marker.proprietary_marker.events.register("mousedown", marker.proprietary_marker, openlayersmarkerclicked);
            }

            i++;

        }

        //Add to list of marker managers allready created
        markermng_zoomlevel.push(zoomlevel);

        //Show markers only for specifed zoom level
        markerszoomlevel(zoomlevel);

    });

} 

}
4

0 に答える 0