marker.setPosition( new google.maps.LatLng( lat, lon ) ); map.panTo( new google.maps.LatLng( lat, lon ) );
test online rck:
http://jsfiddle.net/ric47121/4YbED/5/
marker.setPosition( new google.maps.LatLng( lat, lon ) ); map.panTo( new google.maps.LatLng( lat, lon ) );
<?php $ip = $_SERVER['REMOTE_ADDR']; $json = file_get_contents("http://api.easyjquery.com/ips/?ip=".$ip."&full=true"); $json = json_decode($json,true); echo " <pre>"; print_r($json); ?>
url:
http://www.easyjquery.com/detect-get-clients-ip-address-country-using-javascript-php/
otra forma:
http://freegeoip.appspot.com/
Habilitar
android.permission.INTERNET
public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); //HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php"); HttpPost httppost = new HttpPost("http://192.168.0.18/test/androidpost.php"); try { // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("id", "12345")); nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); Toast.makeText(getBaseContext(), "Enviado con exito: "+response.toString(), Toast.LENGTH_LONG).show(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block Toast.makeText(getBaseContext(), "Error 1: "+e.toString(), Toast.LENGTH_LONG).show(); } catch (IOException e) { // TODO Auto-generated catch block Toast.makeText(getBaseContext(), "Error 2: "+e.toString(), Toast.LENGTH_LONG).show(); } }
package com.example.gpstest2; //import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.provider.Settings; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.view.Menu; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity implements LocationListener { private LocationManager locationManager; TextView t; //private String provider; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.setTitle("test gps rck"); //telnet localhost 5554 //geo fix 30 26 // Get the location manager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); t = (TextView) findViewById(R.id.tit); t.setText("inicio.."); //LocationListener mlocListener = new LocationListener(); //locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener); //locationManager.requestLocationUpdates(provider, 400, 1, this); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 400, 1, this); boolean enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); // Check if enabled and if not send user to the GSP settings // Better solution would be to display a dialog and suggesting to // go to the settings if (!enabled) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); Toast.makeText(getBaseContext(), "gps no esta disponible", Toast.LENGTH_LONG).show(); } Toast.makeText(getBaseContext(), "GPS disponible", Toast.LENGTH_LONG).show(); /* // Define the criteria how to select the locatioin provider -> use // default Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); // Initialize the location fields if (location != null) { System.out.println("Provider " + provider + " has been selected."); onLocationChanged(location); } else { //latituteField.setText("Location not available"); //longitudeField.setText("Location not available"); Toast.makeText(getBaseContext(), "Location not available", Toast.LENGTH_LONG).show(); } */ } @Override protected void onResume() { super.onResume(); //locationManager.requestLocationUpdates(provider, 400, 1, this); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 400, 1, this); } @Override protected void onPause() { super.onPause(); locationManager.removeUpdates(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } public void onLocationChanged(Location loc) { // TODO Auto-generated method stub //loc.getLatitude(); //loc.getLongitude(); String Text = "My current location is: Latitud = " + loc.getLatitude() + " Longitud = " + loc.getLongitude(); Toast.makeText(getBaseContext(), Text, Toast.LENGTH_LONG).show(); t.setText("cambio: " + Text); } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub Toast.makeText( getBaseContext(),"Gps Disabled",Toast.LENGTH_SHORT ).show(); } public void onProviderEnabled(String provider) { // TODO Auto-generated method stub Toast.makeText( getBaseContext(),"Gps Enabled",Toast.LENGTH_SHORT ).show(); } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } }
$('#spinner2').spinner({ min: 2, max: 5 });