﻿var map;
var pinInfobox;

function initialize() {
	

    var mapOptions = {
        credentials:    "ArHsZVhK_qkJn8x_UCkrh9GFgDLNLH_7rIKZwnUAUq025GaZcpA9-l920VKK5dJM",
        center:         new Microsoft.Maps.Location(39.451500, -7.696500),
        mapTypeId:      Microsoft.Maps.MapTypeId.aerial,
        zoom:           15
    }
    
    map = new Microsoft.Maps.Map(document.getElementById("map_canvas"), mapOptions);
    
    // Retrieve the location of the map center 
    var center = map.getCenter();
    
    // Add a pin to the center of the map
    var pin = new Microsoft.Maps.Pushpin(center, {text: '1'}); 
    
    pinInfobox = new Microsoft.Maps.Infobox(pin.getLocation(), 
    {
        title:          'Termas de Nisa', 
        description:    'É aqui o Complexo Termal da Fadagosa de Nisa', 
        visible:        false, 
        offset:         new Microsoft.Maps.Point(0,15)
    });

    // Add handler for the pushpin click event.
    Microsoft.Maps.Events.addHandler(pin, 'click', displayInfobox);

    // Hide the infobox when the map is moved.
    Microsoft.Maps.Events.addHandler(map, 'viewchange', hideInfobox);

    // Add the pushpin and infobox to the map
    map.entities.push(pin);
    map.entities.push(pinInfobox);
}

function displayInfobox(e)
{
    pinInfobox.setOptions({ visible: true });
}                    

function hideInfobox(e)
{
    pinInfobox.setOptions({ visible: false });
}
