var gmap = null
var geocoder = null;
function show_address(address, infocontent)
{
if(geocoder == null)
geocoder = new GClientGeocoder();
geocoder.getLatLng(
address,
function(point) {
if(!point) {
alert("Google hittade inte " + address);
} else {
gmap.setCenter(point, 9);
gmap.openInfoWindowHtml(point, infocontent);
$('map-div').show();
}
}
);
return false;
}
function show_map(lat, lng, infotitle, infotext)
{
infotext = infotext.replace(/, \.$/, '.');
var infocontent = '<dl><dt>' + infotitle + '</dt><dd>' + infotext + '</dd></dl>';
if($('map-div').visible()) {
hide_map();
} else if(GBrowserIsCompatible()) {
if(gmap == null) {
gmap = new GMap2(document.getElementById("map"));
gmap.addControl(new GSmallMapControl());
gmap.addControl(new GMapTypeControl());
gmap.setCenter(new GLatLng(59.346495, 14.499893), 9);
}
if(/^[^\d]/.test(lat)) {
show_address(unescape(lat), infocontent);
} else {
if(/^[A-Z][A-Z]/.test(lat)) {
var ll = ngr2ll(lat);
lat = ll.latitude;
lng = ll.longitude;
}
gmap.setCenter(new GLatLng(lat, lng), 9);
gmap.openInfoWindowHtml(gmap.getCenter(), infocontent);
$('map-div').show();
}
} else {
alert('Din webbläsare stöder tyvärr inte GoogleMaps');
}
return false;
}
function hide_map()
{
$('map-div').hide();
return false;
}