var mapURL = "http://maps.google.com/maps?f=q&hl=en&q="; if (singleResult.address.length > 0) { mapURL += ""; var tmpAddr = singleResult.address.replace(/(\s*#.*$)/, ""); mapURL += tmpAddr.replace(/\s+/g, "+"); } mapURL += "+"; mapURL += singleResult.city.replace(/\s+/g, "+"); mapURL += "+"; mapURL += singleResult.state.replace(/\s+/g, "+"); if (singleResult.zip.length > 0) { mapURL += "+"; mapURL += singleResult.zip.replace(/\s+/g, "+"); } mapURL += "+"; mapURL += "("; mapURL += singleResult.name.replace(/\s+/g, "+"); mapURL += ")"; mapURL += "&btnG=Search&"; // t=h is hybrid, t=m is plain map and t=k is satellite map. Change as desired. mapURL += "t=h";