My  javascript   code  is  this :
function load()
 {
        var explodeLoc = window.location.toString().split('#');
        if(explodeLoc[1]) {
                var anchor = explodeLoc[1];
                var parts = anchor.split('-');
                if(parts[1]){
                        var extra = parts[1];
                }
                if(parts[0] == 'tab' && $(extra)) {
                        Display.choose(extra);
                }
        }
        if($(Display.id) && !Display.now) /* if theres a display object */
        Display.showFirst();
}
   var Display = {
        id: 'show',
        handlerPrefix : 'H',
        handlersId: 'controls',
        handlerActiveClass: 'activeH',
        now: 0,
        handlerDisable: function(id){ if($(id)) $
(id).setAttribute('class',''); },
        handlerDisableAll: function(){
                els = $(this.handlersId).getElementsByTagName('li');
                for(var i=0; i < els.length; i++) {
                        if(els[i].id) {
                                this.handlerDisable(els[i].id); }
                }
        },
        handlerActive: function(id){ if($(id)) $
(id).setAttribute('class',this.handlerActiveClass); },
        $show: function(el){
                if(el) {
                        el.style.display = 'block';
                        this.now = el.id;
                        this.handlerDisableAll();
                        this.handlerActive(this.handlerPrefix+el.id);
                }
        },
        $hide: function(el){
                if(el){
                        el.style.display = 'none';
                        this.now = 0;
                        this.handlerDisable(this.handlerPrefix+el.id);
                }
        },
        show: function(id){ this.$show($(id)); this.now = id;},
        hide: function(id){ this.$hide($(id)); this.now = id;},
        toogle: function(id){ ($(id).style.display=='none')?
this.show(id):this.hide(id);},
        hideAll: function(){
                els = $(this.id).getElementsByTagName('div');
                for(var i=0; i < els.length; i++)
                        if(els[i].className == 'tab') this.$hide(els[i]);
                this.now = 0;
        },
        choose: function(id){ this.hideAll(); this.show(id);},
        showFirst: function(){ this.hideAll(); this.$show($
(this.id).getElementsByTagName('div')[0]); }
}
var GMaps = {
        map: true,
        id: 'map',
        mTypes: [],
        tooltip: document.createElement("div"),
        error: function(e) {
                alert(e);
        },
        newmap: function(lat,lng,zoom) {
                if($(this.id)) {
                        this.map = new GMap2($(this.id));
                        this.map.setCenter(new GLatLng(lat, lng), zoom);
                        this.display();
                        $(this.id).appendChild(this.tooltip);
                        this.tooltip.style.display="none";
                }
                else this.error("error generating map.");
        },
        display: function() {
                this.map.setMapType(G_HYBRID_MAP);
                this.map.enableContinuousZoom();
                this.map.addControl(new GLargeMapControl());
                this.map.addControl(new GMapTypeControl());

                //marker types
                this.mTypes = [];
                this.newMarkerType('place',"GEO_URL_ROOT/images/marker.png");
                this.newMarkerType('spot',"GEO_URL_ROOT/images/marker2.png");
                
this.newMarkerType('start',"GEO_URL_ROOT/images/marker_flag.png");
        },
        newMarkerType: function(type,file){
                var Icon = new GIcon(G_DEFAULT_ICON);
                Icon.image = file;
                this.mTypes[type] = { icon:Icon };
        },
        marker: function(lat,lng,type,html) {
                var latlng = new GLatLng(lat,lng);
                var marker = new GMarker(latlng, this.mTypes[type]);
                marker.tooltip = '<div class="tooltip">'+html+'</div>';
                this.map.addOverlay(marker);
                if(html) {
                        GEvent.addListener(marker,"mouseover", function() {
                                GMaps.showTooltip(marker);
                        });
                        GEvent.addListener(marker,"mouseout", function() {
                                GMaps.tooltip.style.display="none";
                        });
                }

        },
        showTooltip: function(marker) {
                this.tooltip.innerHTML = marker.tooltip;
                var point =
this.map.getCurrentMapType().getProjection().fromLatLngToPixel(this.map.getBounds().getSouthWest(),
this.map.getZoom());
                var offset =
this.map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),
this.map.getZoom());
                var anchor = marker.getIcon().iconAnchor;
                var width = marker.getIcon().iconSize.width;
                var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new
GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y
+anchor.y));
                pos.apply(this.tooltip);
                this.tooltip.style.display="block";
        },
        polyline: function(points,center) {
                var l =  points.length;
                if(l < 1) this.error("Impossible tracks the route. Missing
points.");
                else {
                        if(!this.map){
                                if(center){var latc = center[0]; var lngc = 
center[1];}
                                else { var latc = points[1][0]; var lngc = 
points[1][1]; }
                                this.newmap(latc,lngc,12);
                        }
                        var polyline = [];
                        var latlng = 0;
                        for(var i = 0; i < l; i++){
                                if(points[i]){
                                        latlng = new 
GLatLng(points[i][0],points[i][1]);
                                        polyline.push(latlng);
                                }

                        }
                        polObj = new GPolyline(polyline);
                        this.map.addOverlay(polObj);
                }
        }
}



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to