Demo

LocationBox JavaScript Demos

Get Location

Get Location:    

Instructions

Use the "Get Location" button to show your location on the map. Zoom into the map for details.
See the JavaScript API for more information.

Source Code

The Javascript code for the above map is:

<script language="Javascript" 
	src="http://www.locationbox.com.tr/locationbox/services?
	Key=key&Cmd=APIV2&Typ=JS"></script>

<script language="JavaScript">
var mapper  = new IMapper();

function startup() {
  mapper.initMap(41.046179257461404, 29.02095794373928, 12); 
  mapper.addNavigationPanel();      
  return;
} // startup()
    
  var mapper  = new IMapper();

function getLocation() {
  mapper.getGeolocation(cback);
  return;
}
  
function cback(loc) {
  var x = loc.latitude;
  var y = loc.longitude;
  var accuracy = loc.accuracy;
  mapper.showMapCentered(x, y, 18) ;
  mapper.addMarker('geo_1', x, y, 'LocationMarker', 'M.PIN_1', 70, 70, null);
  var html = '';
  html += '<table>';
  html += '<tr><td>Latitude: </td><td>' + x + '</td></tr>';
  html += '<tr><td>Longitude: </td><td>' + y + '</td></tr>';
  html += '<tr><td>Accuracy: </td><td>' + accuracy + '</td></tr>';
  html += '</table>';
  mapper.displayInfoWindow(x, y, html, 200, 100, "LocationBox");
  return;
}
	
 
    
</script>

Buttons:

  <a href="javascript:getLocation()"><img src="images/add.gif" border=0></a>

					
Download working page
Remember that you need to use your key code as Key attribute.