There is a simple query to google API
https://maps.googleapis.com/maps/api/geocode/json?address=&components=country:Russia&language=ru&key=MY_API_KEY
To get the continent, use point in polygon analysis with your input coordinates (from the address look up), you can get the continent from this FusionTable containing the continent data.
Code snippet (puts the continent in the infowindow).
google.load('visualization', '1', {'packages':['corechart', 'table', 'geomap']});
// no spaces original
var tableid = '1O_WugYFKPBS4GTkPdN_hof6QnldoZlnwtxMjbMU'; // 297050;
var layer;
var circle;
var meters = 0.5;
var lat = 37.4;
var lng = -122.1;
var marker = null;
var geocoder = null;
var infowindow = null;
function findAddress(address) {
if (!address)
var address=document.getElementById("address").value;
if ((address != '') && geocoder) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
if (results && results[0] && results[0].geometry && results[0].geometry.viewport)
map.fitBounds(results[0].geometry.viewport);
if (document.getElementById('address').value != '')
{
map.setCenter(results[0].geometry.location);
infowindow = new google.maps.InfoWindow(
{ content: ''+address+'',
size: new google.maps.Size(150,50)
});
marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title:address
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(''+address+'
'+results[0].geometry.location);
infowindow.open(map,marker);
});
var event = new Object();
event.latLng = results[0].geometry.location;
changeCenter(event);
// layer.setQuery("SELECT geometry FROM "+tableid+" WHERE ST_INTERSECTS(geometry,CIRCLE(LATLNG"+results[0].geometry.location+",1))");
}
} else {
alert("No results found");
}
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
function initialize() {
geocoder = new google.maps.Geocoder();
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(lat, lng),
zoom: 10,
disableDefaultUI: true,
navigationControl: true,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
});
google.maps.event.addListener(map, 'click', function(event) {
changeCenter(event);
});
layer = new google.maps.FusionTablesLayer({
query: {
select: '\'geometry\'',
from: tableid,
where: 'ST_INTERSECTS(\'geometry\', CIRCLE(LATLNG(' + lat + ',' + lng + '),' + meters + '))'
}
});
layer.setMap(map);
circle = new google.maps.Circle({
center: new google.maps.LatLng(lat, lng),
radius: meters,
map: map,
fillOpacity: 0.2,
strokeOpacity: 0.5,
strokeWeight: 1
});
}
function changeRadius(new_meters) {
if (new_meters != "") {
meters = new_meters;
layer.setOptions({
query: {
select: '\'geometry\'',
from: tableid,
where: 'ST_INTERSECTS(\'geometry\', CIRCLE(LATLNG(' + lat + ',' + lng + '),' + meters + '))'
}
});
circle.setRadius(parseInt(meters));
}
}
function changeCenter(event) {
lat = event.latLng.lat();
lng = event.latLng.lng();
layer.setOptions({
query: {
select: '\'geometry\'',
from: tableid,
where: 'ST_INTERSECTS(\'geometry\', CIRCLE(LATLNG(' + lat + ',' + lng + '),' + meters + '))'
}
});
circle.setCenter(event.latLng);
// query table for name, address, delivery
//set the query using the parameter
var queryText ="SELECT \'CONTINENT\', \'geometry\' FROM "+tableid+" WHERE ST_INTERSECTS(\'geometry\', CIRCLE(LATLNG(" + lat + "," + lng + ")," + meters + "));";
document.getElementById('FTQuery').innerHTML = queryText;
queryText = encodeURIComponent(queryText);
document.getElementById('encFTQuery').innerHTML = queryText;
var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq=' + queryText);
//set the callback function
query.send(openInfoWindowOnMarker);
}
function openInfoWindowOnMarker(response) {
if (!response) {
alert('no response');
return;
}
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
FTresponse = response;
//for more information on the response object, see the documentation
//http://code.google.com/apis/visualization/documentation/reference.html#QueryResponse
numRows = response.getDataTable().getNumberOfRows();
numCols = response.getDataTable().getNumberOfColumns();
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('Continent: '+response.getDataTable().getValue(0,0)+'
');
infowindow.open(map,marker);
});
google.maps.event.trigger(marker, 'click');
}
google.maps.event.addDomListener(window, 'load', initialize);
html, body, #map_canvas {
height: 500px;
width: 500px;
margin: 0px;
padding: 0px
}