1

以下のように、マーカーの情報ウィンドウのコンテンツが必要です

代替テキスト

これまでの私のコードは

loadEmbeddedMap : function() {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initEmbeddedMap";
        document.body.appendChild(script)
    },
    initEmbeddedMap : function() {
        var myLatlng = new google.maps.LatLng(40, -80);
        var myOptions = {
                zoom: 8,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById("embeddedGoogleMap"), myOptions);
        geocoder = new google.maps.Geocoder();
        geocoder.geocode( { 'address': $('#userMapAddress').val()}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                marker = new google.maps.Marker({
                    map: map, 
                    position: results[0].geometry.location
                });
                console.debug(results[0]);
                infowindow = new google.maps.InfoWindow();
                var infoWindowContent = "<div><strong>Address:</strong></div>";
                infoWindowContent    += "<div>"+results[0].address_components[0].short_name+","+results[0].address_components[1].short_name+"</div>";
                infoWindowContent    += "<div>"+results[0].address_components[5].short_name+","+results[0].address_components[7].short_name+"</div>";
                //infoWindowContent    += results[0].formatted_address;
                infowindow.setContent(infoWindowContent);
                infowindow.open(map, marker);
            } else {
                //alert("Geocode was not successful for the following reason: " + status);
            }
        });
        $('#embeddedGoogleMapWrapper').show();
    },

上記のコードはこれを出力します

代替テキスト

それらの「道順」、「近くを検索」などを取得するにはどうすればよいですか..? どんな助けでも感謝..

4

1 に答える 1

2

私は読むことから始めます

http://code.google.com/apis/maps/documentation/localsearch/devguide.html#hiworld

私が見ることができるように、あなたが望むことをすることが可能です。明確な答えは得られませんが、手がかりになるかもしれません。少なくとも元の Google フォームにかなり近い情報ウィンドウで独自のフォームを作成し、それらの検索クエリを送信してクリック イベントを処理します。検索結果を処理する必要があるよりも

http://code.google.com/apis/maps/documentation/localsearch/devguide.html#handle_search_results

でいくつかのテストを行います

http://code.google.com/apis/ajax/playground/#the_hello_world_of_local_search

たとえば、localSearch.results[i].lat などから緯度を取得できます。

このことから何かを得られることを願っています

于 2011-03-16T11:38:35.923 に答える