1

我无计可施。

我有一个包含地图的页面 A(名为“地图”的地图对象具有全局范围),以及一个打开子页面 B 的按钮。反过来,页面 B 有一个应该在地图上放置标记的按钮在页面 A 上。相关页面的链接和概要如下:

页面 A: http: //friendsofhillforest.org/maps/HillForestTrailmap-v2-2-topo.html “管理我的标记”按钮在新窗口中打开页面 B

B页:http: //friendsofhillforest.org/maps/tools/marker_mgmt2.html

当页面 B 按钮“选定的地图”尝试在页面 A 的地图上放置标记时,我收到错误消息“错误:属性值无效:[object Object] (main.js:1)”

这是我的代码的概要,因此您不必费力地阅读这些大型脚本:

页面 A:

<body>
    <input type="button" name="location" value="Manage My Markers" title="Manage My Markers" onClick="launchMarkerManager();">
    ...
    <div id="map"></div>
    <script type="text/javascript">
        var map = null;
        ...
        function launchMarkerManager() {
            var newwindow = window.open('http://friendsofhillforest.org/maps/tools/marker_mgmt1.html','Hill Forest Marker Management Tool', document.height - 50, document.width - 50); newwindow.focus();
        }
        ...
        map = new google.maps.Map(document.getElementById('map'), {
            ...
        });
    </script>
</body>

B页:

<body>
    ...
    <input type="button" id="mapchecks" value="Map Selected" onclick="mapChecks(); />
    ...
    <script type="text/javascript">
        ...
        function mapChecks() {
            //add the markers in the results list to the calling map window
            var map = window.opener.map;
            var markerFile = '../icons/numbermarkers/iconr25.png';
            var thisMarker = new google.maps.Marker({
                map: map,
                ...     
            });
            map.setCenter(new google.maps.LatLng(36.5,-74.1));
        }
        ...
    </script>
</body>

我做了很多谷歌搜索和大量搜索 Stack Overflow,但我似乎无法找到这个问题的另一个例子。谁能看到我做错了什么?非常感谢!

4

1 回答 1

0

I can't tell you exactly what the problem is, but it must be caused by the two different documents.

It works for me when I transfer the mapChecks-function(with some modifications, e.g. removing the 1st line) into page A and call opener.mapChecks() in page B

于 2012-09-11T06:42:13.573 回答