This is my first post! I have a question about javascript...here is my code:
<html>
<head>
<title>Geolocation Demo</title>
</head>
<body>
<h1>Geolocation Demo</h1>
<p>Latitude: <span id="lat">0.00</span> Longitude: <span id="lon">0.00</span> City: <span id="city">Loading...</span></p>
<p><a id="city_link" href="http://tinygeocoder.com/" target="_blank">View City</a></p>
<p><a id="gmaps_link" href="http://maps.google.co.uk/" target="_blank">View on Google Maps</a></p>
<script language="javascript">
// show the position on the page and make a google maps link
function showPosition(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
document.getElementById("lat").innerHTML = lat;
document.getElementById("lon").innerHTML = lon;
var gmaps_url = "http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=" + lat + "+" + lon;
var city_url = "http://tinygeocoder.com/create-api.php?g=" + lat + "," + lon;
document.getElementById("gmaps_link").href = gmaps_url;
document.getElementById("city_link").href = city_url;
}
</script>
</body>
</html>
As you can see, this script target my geolocation. Specifically, Lat and Lon are working perfectly. In addinition, i want to display and region info (like city). So, i found a website which i provide the coordinates and it returns me a region name. My question is if i can display the name of region without clicking the link "View city" but in the field "city"...is it possible to pass the webpage content (http://tinygeocoder.com/create-api.php?g=" + lat + "," + lon;) into my webpage? The content of this page is only the name as i said...no html tags!
Thank you!
Use AJAX
After you have the url formed make a ajax request to it, get the results back and parse into your container
You might also want to look at the google geocoder example (as when I checked that service it said it was unavailable)