﻿// JScript File
// === functions that perform the context menu options ===
function zoomIn() 
{
    // perform the requested operation
    map.zoomIn();
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
}      
function zoomOut() 
{
    // perform the requested operation
    map.zoomOut();
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
}      
function zoomInHere() 
{
    // perform the requested operation
    var point = map.fromContainerPixelToLatLng(gClickedPixel)
    map.zoomIn(point,true);
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
}      
function zoomOutHere() 
{
    // perform the requested operation
    var point = map.fromContainerPixelToLatLng(gClickedPixel)
    map.setCenter(point,map.getZoom()-1); // There is no map.zoomOut() equivalent
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
}      
function centreMapHere() 
{
    // perform the requested operation
    var point = map.fromContainerPixelToLatLng(gClickedPixel)
    map.setCenter(point);
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
}  

function createIconMarker(point, number, icon)
{
    var marker = new GMarker(point, icon);
     GEvent.addListener(marker, "click", function(){onMarkerClick(marker, number);});
     return marker;
}
function createTestIconMarker(point, number)
{
    var baseIcon = new GIcon();
    baseIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    baseIcon.iconSize = new GSize(20, 34);
    baseIcon.shadowSize = new GSize(37, 34);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);
    baseIcon.infoShadowAnchor = new GPoint(18, 25);
    return createIconMarker(point, number, baseIcon);
}

function getLatLonFromPixel(x,y) 
{
    var swpixel = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
    var nepixel = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getNorthEast(),map.getZoom());
    return map.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(swpixel.x + x,nepixel.y + y),map.getZoom());
} 