Plotting Points with the Google Maps API - api

I have a project where the client is looking to be able to create an outline around a specific area on a Google Map and have it clickable with the standard Google Maps info window.
So rather than just a standard point being plotted at a specific lat and long location it would need to create multiple points and a stroke/outline.
Does anyone know if this is even possible with the Google Maps api?
Thanks.

Sample code:
toggleCommentMode(true);
function toggleCommentMode(isCommentMode){
if(isCommentMode){
//$("#map img").css("cursor", "crosshair !important");
commentModeEventListener = google.maps.event.addListener(FRbase, 'click', commentListener);
}
else{
//$("#map img").css("cursor", "auto !important");
google.maps.event.removeListener(commentModeEventListener);
}
}
//}}}
function commentListener(evt){
var newMarker = new google.maps.Marker({
position: evt.latLng,
draggable : true,
title : "Drag me; Double click to remove",
map : map
});
google.maps.event.addListener(newMarker, 'dragend',function(){
updateMarkerList();
});
google.maps.event.addListener(newMarker, 'dblclick',function(){
$(myMarkers["userComment"]).each(function(i,marker){
if(marker === newMarker){
marker.setMap(null);
Array.remove(myMarkers["userComment"], i);
updateMarkerList();
}
});
});
if(typeof myMarkers["userComment"] == "undefined"){
myMarkers["userComment"] = [];
}
myMarkers["userComment"].push(newMarker);
updateMarkerList();
}
//update marker list
//{{{
function updateMarkerList(){
$("#commentMarkerList").empty();
var path = [];
if(myMarkers["userComment"].length == 0){
$("#commentAccord .step").hide();
}
else{
$("#commentAccord .step").show();
}
$(myMarkers["userComment"]).each(function(i, marker){
path.push(marker.getPosition());
var listItem = $("<li></li>").addClass("ui-state-default").attr("id", i);
$(listItem).mouseenter(function(){
marker.setShadow("img/highlightmarker.png");
});
$(listItem).mouseleave(function(){
marker.setShadow("");
});
var titleLink = $("<a></a>").attr({
innerHTML : "Point",
href : "javascript:void(0);"
});
var removeLink = $("<a></a>").attr({
innerHTML : "(remove this)",
href : "javascript:void(0);"
});
$(removeLink).click(function(){
marker.setMap(null);
Array.remove(myMarkers["userComment"], i);
updateMarkerList();
});
$(listItem).append(
$("<span></span>").addClass("ui-icon ui-icon-arrowthick-2-n-s")
);
$(listItem).append(titleLink).append(removeLink);
$("#commentMarkerList").append(listItem);
});
if(typeof userCommentPolyline != "undefined"){
userCommentPolyline.setMap(null);
}
var polylineopts = {
path : path,
strokeColor : "#FF0000",
strokeWeight : 5,
strokeOpacity : 1
};
userCommentPolyline = new google.maps.Polyline(polylineopts);
userCommentPolyline.setMap(map);
$("#commentMarkerList").sortable({
placeholder: 'ui-state-highlight',
stop : function(evt, ui){
var newList = [];
$("#commentMarkerList li").each(function(i,listitem){
newList.push(myMarkers["userComment"][parseInt($(listitem).attr("id"))]);
});
myMarkers["userComment"] = newList;
updateMarkerList();
}
});
$("#commentMarkerList").disableSelection();
}
//}}}
//clear User comments
//{{{
function clearUserComments(type){
if(typeof myMarkers[type] !== "undefined"){
$(myMarkers[type]).each(function(i,marker){
marker.setMap(null);
});
myMarkers[type]=[];
if(type == "userComment"){
updateMarkerList();
}
}
}
//}}}
//create comments
//{{{
function createComments(){
$.getJSON('data.aspx',
{"p":"commentdata","d":new Date().getTime()},
function(data){
//console.log(data);
$(data).each(function(i,comment){
//console.log(commentTypes[comment.cat_id-1]);
if(typeof commentTypes[comment.cat_id-1] !== "undefined") {
if(typeof commentTypes[comment.cat_id-1].comments == "undefined"){
commentTypes[comment.cat_id-1]["comments"] = [];
}
//create path and anchor from comment.positions
//{{{
var path = [];
var anchor;
$(comment.positions).each(function(i, position){
var pos = new google.maps.LatLng(
position.lat,
position.lng
);
if(position.anchor){
anchor = pos;
}
path.push(pos);
});
//}}}
var isLine = (path.length > 1);
//marker and poly line creation
//{{{
var iconToShow = (isLine)?
commentTypes[comment.cat_id-1].markerLineImage
: commentTypes[comment.cat_id-1].markerImage;
var marker = new google.maps.Marker({
//map : map,
title : commentTypes[comment.cat_id-1].title,
position : anchor,
icon : iconToShow
});
var polyline = new google.maps.Polyline({
path : path,
strokeColor : "#106999",
strokeWeight : 5,
map : null,
strokeOpacity : 1
});
//}}}
//link bar in infowindow creation
//{{{
var zoomLink = $("<a></a>").attr({
href : "javascript:zoomTo("+anchor.lat()+","+anchor.lng()+",16);javascript:void(0);",
innerHTML : "Zoom here"
}).addClass("infowinlink");
var likeLink = $("<a></a>").attr({
href : "javascript:markerVote("+comment.id+",true);void(0);",
innerHTML : "Like"
}).addClass("infowinlink likelink");
var dislikeLink = $("<a></a>").attr({
href : "javascript:markerVote("+comment.id+",false);void(0);",
innerHTML : "Dislike"
}).addClass("infowinlink dislikelink");
var linkBar = $("<div></div>").addClass('linkbar').append(zoomLink).append(" | ")
.append(likeLink).append(" | ")
.append(dislikeLink);
if(isLine){
var showLineLink = $("<a></a>").attr({
href : "javascript:myMarkers["+comment.id+"].line.setMap(map);$('.toggleLineLink').toggle();void(0);",
innerHTML : "Show line",
id : "infowin-showline"
}).addClass("infowinlink toggleLineLink");
var hideLineLink = $("<a></a>").attr({
href : "javascript:myMarkers["+comment.id+"].line.setMap(null);$('.toggleLineLink').toggle();void(0);",
innerHTML : "Hide line",
id : "infowin-hideline"
}).addClass("infowinlink toggleLineLink");
$(linkBar).append(" | ").append(showLineLink).append(hideLineLink);
}
//}}}
//var content = "<div class='infowin'><h4>"+commentTypes[comment.cat_id-1].title +"</h4><p>"+comment.text+"</p>";
var content = "<div class='infowin'><h4>"+comment.name +"</h4><p>"+comment.text+"</p>";
content += $(linkBar).attr("innerHTML")+"</div>";
//marker click function
//{{{
google.maps.event.addListener(marker, 'click', function(){
infoWin.setContent(content);
infoWin.open(map, marker);
currMarkerDom(comment.id);
});
//}}}
var obj = {"marker": marker, "line":polyline};
commentTypes[comment.cat_id-1].comments.push(obj);
myMarkers[comment.id]=obj;
////myMarkers.all = $.map(myMarkers, function (n,i) { return n; });
//myMarkers.all.push(marker);
markerArray.push(marker);
}});
var isLoad = false;
google.maps.event.addListener(map,'tilesloaded', function () {
if (!isLoad) {
isLoad = true;
mc = new MarkerClusterer(map, markerArray, {maxZoom:16});
}
});
}
);
}
//}}}

Related

Google maps API geolocation + radar places search

I am trying to use both Geolocation and Places from the google maps API to display a map (at my location) with the nearest places around me. The two examples work seperately but not together.
Can anyone tell me why there is a problem with this? am I overwriting the map with another or doing something else wrong?
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyA93l5zPyIvGB7oYGqzLSk28r5XuIs2Do8
&sensor=true&libraries=places"></script>
<script>
var map;
var service;
var marker;
var pos;
function initialize() {
var mapOptions = {
zoom: 15
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: 'Located'
});
map.setCenter(pos);
}, function() {
handleNoGeolocation(true);
});
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(false);
}
var request = {
location:pos,
radius:500,
types: ['store']
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request,callback);
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}
}
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(place.name);
infowindow.open(map, this);
});
}
function handleNoGeolocation(errorFlag) {
if (errorFlag) {
var content = 'Error: The Geolocation service failed.';
} else {
var content = 'Error: Your browser doesn\'t support geolocation.';
}
var options = {
map: map,
position: new google.maps.LatLng(60, 105),
content: content
};
var infowindow = new google.maps.InfoWindow(options);
map.setCenter(options.position);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
EDIT
Moved the code now so it looks like - Has not fixed the problem of location being undefined.
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var request = {
location:pos,
radius:500,
types: ['store']
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request,callback);
pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: 'Located'
});
map.setCenter(pos);
}, function() {
handleNoGeolocation(true);
});'
Because of async call to navigator.geolocation.getCurrentPosition() which returns immediately, location property of request is undefined. Call to
service.nearbySearch(request,callback);
complains that location is missing. And that is true because pos is not set at that moment.
You have to move this part of code:
var request = {
location:pos,
radius:500,
types: ['store']
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request,callback);
to
navigator.geolocation.getCurrentPosition(function(position) {
...
map.setCenter(pos);
and make variable infoWindow global.
This is changed initialize() function:
var map;
var service;
var marker;
var pos;
var infowindow;
function initialize() {
var mapOptions = {
zoom: 15
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
console.log(map);
// Try HTML5 geolocation
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: 'Located'
});
map.setCenter(pos);
var request = {
location:pos,
radius:500,
types: ['store']
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request,callback);
}, function() {
handleNoGeolocation(true);
});
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(false);
}
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
console.log('after / to createMarker');
createMarker(results[i]);
}
}
}
}

marker clusterer doesn't cluster when zoom

i'm trying to learn google api and i want to use marker clusterer. i create a database
from here and do whatever google said. my code is
`
<script src="markerclusterer.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var customIcons = {
restaurant: {
icon: 'images/pin1.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
bar: {
icon: 'images/pin2.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
};
function initialize() {
var markers = null;
var mcmarkers = [];
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(47.6145, -122.3418),
zoom: 12,
mapTypeId: 'satellite'
});
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl("phpsqlajax_genxml.php", function(data) {
var xml = data.responseXML;
markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"))
var point = new google.maps.LatLng(lat, lng);
var html = "<b>" + name + "</b> <br/>" + address;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
mcmarkers.push(marker);
var mc = new MarkerClusterer(map, mcmarkers);
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('POST', url, true);
request.send(null);
}
function doNothing() {}
//]]>
google.maps.event.addDomListener(window, 'load', initialize);
`
it works well when i open for the first time but when i zoom in or out there was no clusters except max zoom out. i couldn't figure it out. thanks for your help...
var mc = new MarkerClusterer(map, mcmarkers);
This line cannot be placed inside the for loop. but outside after it. I did exactly the same mistake:).

how to to process result of google distance matrix api further?

i am new to programming.. i have this code which gives distance between two points but need to further multiply it by an integer say 10.. the project i am working on is abt calculating distance between two points and multiplying it with fare/Km like Rs.10/km (Indian Rupees) for the same. So if the distance is 30 km the fare would be 30*10 = Rs.300
Thanks in advance
following is the code
<script>
var map;
var geocoder;
var bounds = new google.maps.LatLngBounds();
var markersArray = [];
var origin1 = '';
var destinationA = '';
var destinationIcon = 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=D|FF0000|000000';
var originIcon = 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=O|FFFF00|000000';
function initialize() {
var opts = {
center: new google.maps.LatLng(55.53, 9.4),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), opts);
var fromText = document.getElementById('FAdd');
var options = {
componentRestrictions: {country: 'in'}
};var fromAuto = new google.maps.places.Autocomplete(fromText, options);
fromAuto.bindTo('bound', map);
var toText = document.getElementById('TAdd');
var toAuto = new google.maps.places.Autocomplete(toText, options);
toAuto.bindTo('bound', map);
geocoder = new google.maps.Geocoder();
}
function calculateDistances() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [document.getElementById("FAdd").value],
destinations: [document.getElementById("TAdd").value],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
function callback(response, status) {
if (status != google.maps.DistanceMatrixStatus.OK) {
alert('Error was: ' + status);
} else {
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
var outputDiv = document.getElementById('outputDiv');
outputDiv.innerHTML = '';
deleteOverlays();
for (var i = 0; i < origins.length; i++) {
var results = response.rows[i].elements;
addMarker(origins[i], false);
for (var j = 0; j < results.length; j++) {
addMarker(destinations[j], true);
outputDiv.innerHTML += results[j].distance.text + '<br>';
}
}
}
}
function addMarker(location, isDestination) {
var icon;
if (isDestination) {
icon = destinationIcon;
} else {
icon = originIcon;
}
geocoder.geocode({'address': location}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
bounds.extend(results[0].geometry.location);
map.fitBounds(bounds);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
icon: icon
});
markersArray.push(marker);
} else {
alert('Geocode was not successful for the following reason: '
+ status);
}
});
}
function deleteOverlays() {
if (markersArray) {
for (i in markersArray) {
markersArray[i].setMap(null);
}
markersArray.length = 0;
}
}
</script>
I use an Ajax call to PHP, and haven't yet used getDistanceMatrix(), but this should be an easy fix.
First, if you know you will always only have one origin and one destination, you don't need the "for" loop in your callback function. Second, you're taking the distance text rather than the distance value.
function callback(response, status) {
if (status != google.maps.DistanceMatrixStatus.OK) {
[...]
} else {
deleteOverlays();
var outputDiv = document.getElementById('outputDiv'),
origin = response.originAddresses[0],
destination = response.destinationAddresses[0],
result = response.rows[0].elements[0],
distance = result.distance.value,
text = result.distance.text,
price = 10 * distance;
outputDiv.innerHTML = '<p>' + text + ': Rs.' + price + '</p>';
addMarker(origin, false);
addMarker(destination, false);
}
}
I haven't tested this, so it probably needs to be tweaked. ( See https://developers.google.com/maps/documentation/distancematrix/#DistanceMatrixResponses )

YouTube in UIWebView only plays once

I have a UIWebView with some YouTube Videos embeded via the iframe code:
<iframe width="190" height="102" src="http://www.youtube.com/embed/...?showinfo=0" frameborder="0" allowfullscreen></iframe>
When it first loads it is possible to view each video exactly once. After viewing it the area is just black with white "Youtube" in it.
Any ideas? Of course reloading the UIWebView after watching a video fixes it, but I don't like this...
I did it! The following Javascript did the job:
<script>
VideoIDs = new Array(...some ids here...);
function getFrameID(id){
var elem = document.getElementById(id);
if (elem) {
if(/^iframe$/i.test(elem.tagName))
return id;
var elems = elem.getElementsByTagName("iframe");
if (!elems.length)
return null;
for (var i=0; i<elems.length; i++) {
if (/^https?:\/\/(?:www\.)?youtube(?:-nocookie)?\.com(\/|$)/i.test(elems[i].src))
break;
}
elem = elems[i];
if (elem.id)
return elem.id;
do {
id += "-frame";
} while (document.getElementById(id));
elem.id = id;
return id;
}
return null;
}
var YT_ready = (function(){
var onReady_funcs = [], api_isReady = false;
return function(func, b_before){
if (func === true) {
api_isReady = true;
for (var i=0; i<onReady_funcs.length; i++){
onReady_funcs.shift()();
}
} else if(typeof func == "function") {
if (api_isReady)
func();
else
onReady_funcs[b_before?"unshift":"push"](func);
}
}
})();
function onYouTubePlayerAPIReady() {
YT_ready(true)
}
(function(){
var s = document.createElement("script");
s.src = "http://www.youtube.com/player_api";
var before = document.getElementsByTagName("script")[0];
before.parentNode.insertBefore(s, before);
})();
var players = new Array();
YT_ready(function() {
for(index in VideoIDs) {
var frameID = getFrameID(VideoIDs[index]);
if (frameID) {
players[frameID] = new YT.Player(frameID, {
events: {
"onStateChange": stateChange
}
});
}
}
});
function youtube_parser(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[7].length==11){
return match[7];
}
}
function stateChange(event) {
if(event.data == YT.PlayerState.ENDED){
document.location = 'callback:finished';
document.getElementById(youtube_parser(event.target.getVideoUrl())).contentWindow.location.reload(true);
}
}
</script>

google maps api v2 map.removeOverlay() marker array issue

To start off with, I would like to say that I have been looking on the internet for a really long time and have been unable to find the answer, hence my question here.
My latest school project is to create an admin page for adding articles to a database, the articles are connected to a point on a google map. The requirement for adding the point on the map is that the user is able to click the map once and the marker is produced, if the map is clicked a second time the first marker is moved to the second location. (this is what I am struggling with.)
The problem is, as the code is now, I get the error that markersArray is undefined. If I place the var markersArray = new Array; underneath the eventListener then I get an error that there is something wrong the main.js (googles file) and markersArray[0] is undefined in the second if.
By the way, I have to use google maps API v2, even though it is old.
<script type="text/javascript">
//<![CDATA[
var map;
var markers = new Array;
function load() {
if (GBrowserIsCompatible()) {
this.counter = 0;
this.map = new GMap2(document.getElementById("map"));
this.map.addControl(new GSmallMapControl());
this.map.addControl(new GMapTypeControl());
this.map.setCenter(new GLatLng(57.668911, 15.203247), 7);
GDownloadUrl("genxml.php", function(data) {
var xml = GXml.parse(data);
var Articles = xml.documentElement.getElementsByTagName("article");
for (var i = 0; i < Articles.length; i++) {
var id = Articles[i].getAttribute("id");
var title = Articles[i].getAttribute("title");
var text = Articles[i].getAttribute("text");
var searchWord = Articles[i].getAttribute("searchWord");
var point = new GLatLng(parseFloat(Articles[i].getAttribute("lat")),
parseFloat(Articles[i].getAttribute("lng")));
var article = createMarker(point, id, title, text);
this.map.addOverlay(article);
}
});
}
var myEventListener = GEvent.bind(this.map,"click", this, function(overlay, latlng) {
if (this.counter == 0) {
if (latlng) {
var marker = new GMarker(latlng);
latlng1 = latlng;
this.map.addOverlay(marker);
this.counter++;
markers.push(marker); //This is where I get the error that markersArray is undefined.
}
}
else if (this.counter == 1) {
if (latlng){
alert (markers[0]);
this.map.removeOverlay(markers[0]);
var markers = [];
this.map.addOverlay(marker);
this.counter++;
}
}
});
}
function createMarker(point, id, title, text) {
var article = new GMarker(point);
var html = "<b>" + title + "</b> <br/>"
GEvent.addListener(article, 'click', function() {
window.location = "article.php?id=" + id;
});
return article;
}
I solved the problem. I'm not exactly sure why it worked but this is what it looks like now:
var markersArray = [];
function load() {
if (GBrowserIsCompatible()) {
this.counter = 0;
this.map = new GMap2(document.getElementById("map"));
this.map.addControl(new GSmallMapControl());
this.map.addControl(new GMapTypeControl());
this.map.setCenter(new GLatLng(57.668911, 15.203247), 7);
GDownloadUrl("genxml.php", function(data) {
var xml = GXml.parse(data);
var Articles = xml.documentElement.getElementsByTagName("article");
for (var i = 0; i < Articles.length; i++) {
var id = Articles[i].getAttribute("id");
var title = Articles[i].getAttribute("title");
var text = Articles[i].getAttribute("text");
var searchWord = Articles[i].getAttribute("searchWord");
var type = Articles[i].getAttribute("type");
var point = new GLatLng(parseFloat(Articles[i].getAttribute("lat")),
parseFloat(Articles[i].getAttribute("lng")));
var article = createMarker(point, id, title, text);
this.map.addOverlay(article);
}
});
}
var myEventListener = GEvent.bind(this.map,"click", this, function(overlay, latlng) {
var marker = new GMarker(latlng);
if (this.counter == 0) {
if (latlng) {
latlng1 = latlng;
this.map.addOverlay(marker);
markersArray.push(marker);
this.counter++;
}
}
else if (this.counter == 1) {
if (latlng){
this.map.removeOverlay(markersArray[0]);
this.map.addOverlay(marker);
this.counter++;
}
}
});
}
function createMarker(point, id, title, text) {
var article = new GMarker(point);
var html = "<b>" + title + "</b> <br/>"
GEvent.addListener(article, 'click', function() {
window.location = "article.php?id=" + id;
});
return article;
}