谷歌地图api - 插入“如何从这里到达,到这里”作为叠加?

时间:2010-01-18 15:31:32

标签: google-maps google-api

我一直在使用谷歌地图api,我需要显示我所了解的标准叠加层,显示地址和“如何从这里到达这里”,“到这里”,“在这里应用缩放”的链接等

我让叠加层像这样工作,但它不是标准的,我可以自定义它...有没有办法插入标准叠加层,如上所述?

以下是我插入自定义叠加层的代码

        var marker = new GMarker(point);  // Create the marker
        map.addOverlay(marker);           // And add it to the map

        // And open some infowindow, with some HTML text in it
        marker.openInfoWindowHtml(
    'This is my test!!!, <strong>test </strong>'
    );

任何真正有用的帮助

由于

1 个答案:

答案 0 :(得分:0)

据我所知,没有标准的叠加层。这是有用的代码。您可以根据需要更改info参数来添加功能。

if( GBrowserIsCompatible() ) {
    walkmap = new GMap2( document.getElementById( "walkmap" ) ) ;
    walkmap.setCenter( new GLatLng( 11.22,-33.44 ), 16 ) ;
    walkmap.setMapType( G_HYBRID_MAP ) ;

    var baseIcon = new GIcon();
    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    baseIcon.iconSize = new GSize(20, 34);
    baseIcon.shadowSize = new GSize(37, 34);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 34);
    baseIcon.infoShadowAnchor = new GPoint(18, 25);

    var Marker = function( point, info, image ) {
        var point = point ;
        var icon = new GIcon( baseIcon ) ;
        icon.image = image ;
        var marker = new GMarker( point, icon ) ;
        marker.info = info ;
        marker.showInfo = function() {
            this.openInfoWindowHtml( this.info ) ;
        }
        GEvent.addListener( marker, "click", function() {
            marker.showInfo() ;
        });
        walkmap.addOverlay( marker ) ;
        return marker ;
    }

    new Marker( new GLatLng( 11.22,-33.44 ), "My marker", "http://www.google.com/intl/en_us/mapfiles/dd-start.png" ) ;
}