***** JAVASCRIPT EN EL HEAD *****
// Conseguir la clave para el mapa en http://www.google.com/apis/maps/
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=AQUI VA LA CLAVE"></script>
<script type="text/javascript">
//<![CDATA[
window.onload = mapasGoogle;
window.onunload= GUnload;
function mapasGoogle() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("mapaGoogle"));
map.setCenter(new GLatLng(42.8475, -2.6820), 15); //Defino las coordenadas y nivel de zoom
map.setMapType(G_HYBRID_TYPE); //Defino el tipo de mapa: hibrido
map.addControl(new GSmallMapControl()); //Activo controles de movimiento y zoom del mapa
map.addControl(new GMapTypeControl()); //Activo controles de tipo de mapa
map.openInfoWindowHtml(map.getCenter(),
("<img src='images/logo.png' width='20' height='20' style='float:left; margin-right:10px' alt='' /><em>Titulo</em> <br /> Lorem ipsum dolor sit amet"));
}
}
//]]>
</script>
***** HTML *****
<div id="mapaGoogle" style="width:500px; height:400px"></div>
/*
* Author URL: http://adomas.org/javascript-mouse-wheel/
*/
/** This is high-level function.
* It must react to delta being more/less than zero.
*/
function handle(delta) {
if (delta < 0)
…;
else
…;
}
/** Event handler for mouse wheel event.
*/
function wheel(event){
var delta = 0;
if (!event) /* For IE. */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta/120;
/** In Opera 9, delta differs in sign as compared to IE.
*/
if (window.opera)
delta = -delta;
} else if (event.detail) { /** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
delta = -event.detail/3;
}
/** If delta is nonzero, handle it.
* Basically, delta is now positive if wheel was scrolled up,
* and negative, if wheel was scrolled down.
*/
if (delta)
handle(delta);
}
/** Initialization code.
* If you use your own event management code, change it as required.
*/
if (window.addEventListener)
/** DOMMouseScroll is for mozilla. */
window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;
// this will iterate with each element with the class 'ie-fix-opacity' and add an IE filter,
// replacing the background-image for the filter of that image
var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
var cBGImg = poElement.currentStyle.backgroundImage;
var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "', sizingMethod='scale')";
poElement.style.backgroundImage = "none";
});
}
// Image Preloader v1.0.1
// documentation: http://www.dithered.com/javascript/image_preloader/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
function preloadImages() {
if (document.images) {
for (var i = 0; i < preloadImages.arguments.length; i++) {
(new Image()).src = preloadImages.arguments[i];
}
}
}
function checkMail(email){
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email)) {
return true;
}
return false;
}
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}