jQuery Virtual Earth Example (Inline)

2 Bradford Close, Exmouth, EX8 5PF

Code

        <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"></script>
        <script charset="UTF-8" type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-gb"></script>

        <style type="text/css">
            body { font-family: Sans-Serif; }
            .address { border: solid 1px #000; height: 500px; position: relative; width: 500px; }
        </style>
        
        <!-- The following script would normally be placed in a separate, external file. -->
        <script type="text/javascript">
            if (!jQuery.generateId) {
                jQuery.generateId = function() {
                    return arguments.callee.prefix + arguments.callee.count++;
                };
                jQuery.generateId.prefix = 'jq$';
                jQuery.generateId.count = 0;

                jQuery.fn.generateId = function() {
                    return this.each(function() {
                        this.id = $.generateId();
                    });
                };
            }

            jQuery.fn.createInlineVirtualEarthMap = function() {
                return this.each(function() {
                    if (!this.id) {
                        $(this).generateId();
                    }

                    var address = $(this).text();
                    var map = new VEMap(this.id);

                    map.LoadMap();
                    map.HideDashboard();
                    map.Find(null, address, null, null, 0, 1, true, true, true, true, function() { map.SetZoomLevel(16); });
                });
            }
        </script>
        
        <script type="text/javascript">
            $(function() {
                $('.address').createInlineVirtualEarthMap();
            });
        </script>