﻿var map;
var geocoder;
var linkUrl;
var projectName;

function addAddressToMap(response) {
	url = window.linkUrl;
	project = window.projectName;
	map.clearOverlays();
	if (!response || response.Status.code != 200) {
		alert("Sorry, we were unable to geocode that address");
	}
	else {
		place = response.Placemark[0];
		point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
		marker = new GMarker(point);
		map.addOverlay(marker);
	}
}

function getLatLngForLocation(point)
{
    map.setCenter(point, 14);
	marker = new GMarker(point);
	map.addOverlay(marker);
}

function showLocationNoMark(address)
{
	geocoder.getLatLng(address, getLatLngForLocation)	
}
			
function showLocation(address,url,project) {
	linkUrl = url;
	projectName = project;
	geocoder.getLocations(address, addAddressToMap);
}

