开发者

Google maps api - inserting "How to arrive from here, to here" as an overlay?

I have been using the google maps api and i need to display from what i understand is a standard overlay that displays the Address and links of "how to arrive from here here", "to here", "apply zoom here" etc.

I got the overlay working like this but its not standard, i can customize it... is there a way to insert the standard overlay as explained above?

Here is my code for inserting a custom overlay

开发者_运维百科
        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>'
    );

Any help really appeciated

Thanks


As far as I know there is no standard overlay. Here's the code that'll help. You may add functionality by changing info parameter as desired.

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" ) ;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜