1

私は機知に富んでいます。

マップを含むページA('map'という名前のMapオブジェクトにはグローバルスコープがあります)と、子ページ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のマップにマーカーを配置しようとすると、「エラー:プロパティの値が無効です:[オブジェクトオブジェクト](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>

私はたくさんのグーグルとStackOverflowの検索をたくさんしましたが、この問題の別の例を見つけることができないようです。誰かが私が間違っていることを見ることができますか?どうもありがとう!

4

1 に答える 1

0

問題が何であるかを正確に伝えることはできませんが、2つの異なるドキュメントが原因である必要があります。

mapChecks-function(1行目を削除するなどの変更を加えたもの)をページAに転送しopener.mapChecks()、ページBを呼び出すと機能します。

于 2012-09-11T06:42:13.573 に答える