SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function load() not works.


    I have a Javascript source code that :
    Code:
    function $(e){return document.getElementById(e);}
    
    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();	
    }
    function searchCheck() {
    	var q = $('searchQuery');
    	if(q.value == '') { q.style.backgroundColor = '#FFFFE0'; q.focus(); return false;}
    	return true;
    }
    function emptyForm(id) {
    	var inputs = $(id).getElementsByTagName('input');
    	for(var i= 0; i<inputs.length; i++){
    		if(inputs[i].value == '') {
    			inputs[i].style.backgroundColor = '#FFFDA3';
    			return true;
    		}
    	}
    	return false;
    }
    function loadingButton(el)
    {
    	el.disabled = true; 
    	el.value = 'Loading...';
    	return true;
    }
    
    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 Panoramio = {
    	baseURL: 'http://www.panoramio.com/map/get_panoramas.php?',
    	order: 'popularity',
    	size: 'small',
    	amount: 11,
    	from: 0,
    	to: 11,
    	minx: 0, miny: 0, maxx: 0, maxy: 0,
    	incrpage: function() {
    		this.from += this.amount;
    		this.to += this.amount;
    	},
    	insert: function(p){ 
    		var li = document.createElement('li');
    		var aim = document.createElement('a');
    		var im = document.createElement('img');
    		var pa = document.createElement('p');
    		var a = document.createElement('a');
    		
    		aim.href = p.photo_url;
    		im.src = p.photo_file_url;
    		aim.appendChild(im);
    		li.appendChild(aim);
    		
    		a.href = p.owner_url;
    		a.innerHTML = p.owner_name;
    		
    		pa.innerHTML = p.photo_title+'<br> De ';
    		pa.appendChild(a)
    		li.appendChild(pa);
    		
    		$('panoramio').appendChild(li);
    	},
    	message: function(m) {
    		$('panoramio').innerHTML = '<li>'+m+'</li>';
    	},
    	clean: function() { $('panoramio').innerHTML = ''; },
    	store: function(po) {
    		p = po.photos;
    		if(p.length <1) this.message('Any photo found');
    		else {
    			this.clean();
    			for(var i=0; i<p.length; i++)
    				this.insert(p[i]);
    			if(po.count > p.length+this.from) {
    				var li = document.createElement('li');
    				var link = document.createElement('a');
    				link.onclick = function(){
    					Panoramio.incrpage();
    					Panoramio.restore();
    					return false;
    				};
    				link.href = "http://www.panoramio.com/map/#lt="+this.maxy+"&ln="+this.maxx+"&z=4&k=1&a=1&tab=1";
    				link.innerHTML = ' See more pictures;';
    				link.setAttribute('class','last');
    				li.appendChild(link);
    				$('panoramio').appendChild(li);
    			}
    		}
    	},
    	query: function(minx,miny,maxx,maxy) {
    		this.message('Loading photos...');
    		this.minx = minx; this.miny = miny; this.maxx = maxx; this.maxy = maxy;
    		var s = document.createElement('script');
    		s.setAttribute('type', 'text/javascript');
    		s.setAttribute('src',this.baseURL+'order='+this.order+'&size='+this.size+'&set=full&from='+this.from+'&to='+this.to+'&minx='+minx+'&miny='+miny+'&maxx='+maxx+'&maxy='+maxy+'&callback=Panoramio.store');
    		document.getElementsByTagName('head')[0].appendChild(s);
    	},
    	restore: function() {
    		this.query(this.minx,this.miny,this.maxx,this.maxy);
    	}
    };
    
    var GMaps = {
    	map: false,
    	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',"http://djalmabina.100webspace.net/images/marker.png");
    		this.newMarkerType('spot',"djalmabina.100webspace.net/images/marker2.png"); 
    		this.newMarkerType('start',"djalmabina.100webspace.net/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(lat,lng,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); 
    		}
    	}
    };
    However it is not loading a Google Map in my page that :
    http://djalmabina.100webspace.net/index.php?r=4#tab-map
    But only the Internet Explorer browser shows Javascript error alert.
    Mozilla Firefox not display any error in the Javascript console.
    Thanks for some reply.

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function load().

    Please do we can tell me if this script has some syntax error ?
    Code:
    function $(e){return document.getElementById(e);}
    
    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();	
    }
    function searchCheck() {
    	var q = $('searchQuery');
    	if(q.value == '') { q.style.backgroundColor = '#FFFFE0'; q.focus(); return false;}
    	return true;
    }
    function emptyForm(id) {
    	var inputs = $(id).getElementsByTagName('input');
    	for(var i= 0; i<inputs.length; i++){
    		if(inputs[i].value == '') {
    			inputs[i].style.backgroundColor = '#FFFDA3';
    			return true;
    		}
    	}
    	return false;
    }
    function loadingButton(el)
    {
    	el.disabled = true; 
    	el.value = 'Loading...';
    	return true;
    }
    
    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 Panoramio = {
    	baseURL: 'http://www.panoramio.com/map/get_panoramas.php?',
    	order: 'popularity',
    	size: 'small',
    	amount: 11,
    	from: 0,
    	to: 11,
    	minx: 0, miny: 0, maxx: 0, maxy: 0,
    	incrpage: function() {
    		this.from += this.amount;
    		this.to += this.amount;
    	},
    	insert: function(p){ 
    		var li = document.createElement('li');
    		var aim = document.createElement('a');
    		var im = document.createElement('img');
    		var pa = document.createElement('p');
    		var a = document.createElement('a');
    		
    		aim.href = p.photo_url;
    		im.src = p.photo_file_url;
    		aim.appendChild(im);
    		li.appendChild(aim);
    		
    		a.href = p.owner_url;
    		a.innerHTML = p.owner_name;
    		
    		pa.innerHTML = p.photo_title+'<br> De ';
    		pa.appendChild(a)
    		li.appendChild(pa);
    		
    		$('panoramio').appendChild(li);
    	},
    	message: function(m) {
    		$('panoramio').innerHTML = '<li>'+m+'</li>';
    	},
    	clean: function() { $('panoramio').innerHTML = ''; },
    	store: function(po) {
    		p = po.photos;
    		if(p.length <1) this.message('Any photo found');
    		else {
    			this.clean();
    			for(var i=0; i<p.length; i++)
    				this.insert(p[i]);
    			if(po.count > p.length+this.from) {
    				var li = document.createElement('li');
    				var link = document.createElement('a');
    				link.onclick = function(){
    					Panoramio.incrpage();
    					Panoramio.restore();
    					return false;
    				};
    				link.href = "http://www.panoramio.com/map/#lt="+this.maxy+"&ln="+this.maxx+"&z=4&k=1&a=1&tab=1";
    				link.innerHTML = ' See more pictures;';
    				link.setAttribute('class','last');
    				li.appendChild(link);
    				$('panoramio').appendChild(li);
    			}
    		}
    	},
    	query: function(minx,miny,maxx,maxy) {
    		this.message('Loading photos...');
    		this.minx = minx; this.miny = miny; this.maxx = maxx; this.maxy = maxy;
    		var s = document.createElement('script');
    		s.setAttribute('type', 'text/javascript');
    		s.setAttribute('src',this.baseURL+'order='+this.order+'&size='+this.size+'&set=full&from='+this.from+'&to='+this.to+'&minx='+minx+'&miny='+miny+'&maxx='+maxx+'&maxy='+maxy+'&callback=Panoramio.store');
    		document.getElementsByTagName('head')[0].appendChild(s);
    	},
    	restore: function() {
    		this.query(this.minx,this.miny,this.maxx,this.maxy);
    	}
    };
    
    var GMaps = {
    	map: false,
    	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',"http://djalmabina.100webspace.net/images/marker.png");
    		this.newMarkerType('spot',"djalmabina.100webspace.net/images/marker2.png"); 
    		this.newMarkerType('start',"djalmabina.100webspace.net/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(lat,lng,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); 
    		}
    	}
    };
    Thanks for some reply.

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,906
    Mentioned
    139 Post(s)
    Tagged
    2 Thread(s)
    Why don't you install FireFox with FireBug, open the page containing this script, and see for yourself?
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jacvascript error ?

    Please do we can tell me if this script has some syntax error ?
    Code:
    function $(e){return document.getElementById(e);}
    
    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();	
    }
    function searchCheck() {
    	var q = $('searchQuery');
    	if(q.value == '') { q.style.backgroundColor = '#FFFFE0'; q.focus(); return false;}
    	return true;
    }
    function emptyForm(id) {
    	var inputs = $(id).getElementsByTagName('input');
    	for(var i= 0; i<inputs.length; i++){
    		if(inputs[i].value == '') {
    			inputs[i].style.backgroundColor = '#FFFDA3';
    			return true;
    		}
    	}
    	return false;
    }
    function loadingButton(el)
    {
    	el.disabled = true; 
    	el.value = 'Loading...';
    	return true;
    }
    
    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 Panoramio = {
    	baseURL: 'http://www.panoramio.com/map/get_panoramas.php?',
    	order: 'popularity',
    	size: 'small',
    	amount: 11,
    	from: 0,
    	to: 11,
    	minx: 0, miny: 0, maxx: 0, maxy: 0,
    	incrpage: function() {
    		this.from += this.amount;
    		this.to += this.amount;
    	},
    	insert: function(p){ 
    		var li = document.createElement('li');
    		var aim = document.createElement('a');
    		var im = document.createElement('img');
    		var pa = document.createElement('p');
    		var a = document.createElement('a');
    		
    		aim.href = p.photo_url;
    		im.src = p.photo_file_url;
    		aim.appendChild(im);
    		li.appendChild(aim);
    		
    		a.href = p.owner_url;
    		a.innerHTML = p.owner_name;
    		
    		pa.innerHTML = p.photo_title+'<br> De ';
    		pa.appendChild(a)
    		li.appendChild(pa);
    		
    		$('panoramio').appendChild(li);
    	},
    	message: function(m) {
    		$('panoramio').innerHTML = '<li>'+m+'</li>';
    	},
    	clean: function() { $('panoramio').innerHTML = ''; },
    	store: function(po) {
    		p = po.photos;
    		if(p.length <1) this.message('Any photo found');
    		else {
    			this.clean();
    			for(var i=0; i<p.length; i++)
    				this.insert(p[i]);
    			if(po.count > p.length+this.from) {
    				var li = document.createElement('li');
    				var link = document.createElement('a');
    				link.onclick = function(){
    					Panoramio.incrpage();
    					Panoramio.restore();
    					return false;
    				};
    				link.href = "http://www.panoramio.com/map/#lt="+this.maxy+"&ln="+this.maxx+"&z=4&k=1&a=1&tab=1";
    				link.innerHTML = ' See more pictures;';
    				link.setAttribute('class','last');
    				li.appendChild(link);
    				$('panoramio').appendChild(li);
    			}
    		}
    	},
    	query: function(minx,miny,maxx,maxy) {
    		this.message('Loading photos...');
    		this.minx = minx; this.miny = miny; this.maxx = maxx; this.maxy = maxy;
    		var s = document.createElement('script');
    		s.setAttribute('type', 'text/javascript');
    		s.setAttribute('src',this.baseURL+'order='+this.order+'&size='+this.size+'&set=full&from='+this.from+'&to='+this.to+'&minx='+minx+'&miny='+miny+'&maxx='+maxx+'&maxy='+maxy+'&callback=Panoramio.store');
    		document.getElementsByTagName('head')[0].appendChild(s);
    	},
    	restore: function() {
    		this.query(this.minx,this.miny,this.maxx,this.maxy);
    	}
    };
    
    var GMaps = {
    	map: false,
    	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',"http://djalmabina.100webspace.net/images/marker.png");
    		this.newMarkerType('spot',"djalmabina.100webspace.net/images/marker2.png"); 
    		this.newMarkerType('start',"djalmabina.100webspace.net/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(lat,lng,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); 
    		}
    	}
    };
    Thanks for some reply.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,021
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    donovan68, please do not post the same question in multiple forums

    it means extra work for us to combine them all again

    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Please provide a link to a web page. many of us don't have the other bits needed to get your sample code working.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •