Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #
- # M.S.I. Angel Cantu Jauregui
- # angel.cantu [a] sie-group.net
- # http://www.sie-group.net
- #
- include( "modulos/modulos.php" );
- define( API_GOOGLEMAPS, "HASH_API_GOOGLE" );
- define( GOOGLEMAPS_SERVER, "maps.google.com" ); # servidor de apis
- if( API_GOOGLEMAPS )
- {
- define( GOOGLEMAPS_STATICMAP, "/maps/api/staticmap?key=". API_GOOGLEMAPS ); # mapas estaticos
- define( GOOGLEMAPS_GEOCODEJSON, "/maps/api/geocode/json?key=". API_GOOGLEMAPS. "&" ); # mapas geocode por json
- define( GOOGLEMAPS_GEOCODEXML, "/maps/api/geocode/xml?key=". API_GOOGLEMAPS. "&" ); # mapas geocode por xml
- define( GOOGLEMAPS_GEOCODEJS, "/maps/api/js?key=". API_GOOGLEMAPS. "&" ); # mapas geocode por javascript
- }
- else
- {
- define( GOOGLEMAPS_STATICMAP, "/maps/api/staticmap?" ); # mapas estaticos
- define( GOOGLEMAPS_GEOCODEJSON, "/maps/api/geocode/json?" ); # mapas geocode por json
- define( GOOGLEMAPS_GEOCODEXML, "/maps/api/geocode/xml?" ); # mapas geocode por xml
- define( GOOGLEMAPS_GEOCODEJS, "/maps/api/js?" ); # mapas geocode por javascript
- }
- define( GOOGLEMAPS_SENSOR, "false" ); # sensor google maps false o true
- if( $_GET["place"] || $_GET["data"] ) # si hay lugar a identificar
- {
- if( !$_GET["data"] && $_GET["place"] ) # si no es latitud y longitud
- {
- $args= 'address='. urlencode($_GET["place"]). '&sensor='. GOOGLEMAPS_SENSOR;
- $datos= array( 'GET', GOOGLEMAPS_GEOCODEXML.$args );
- $r= socket_iodata( GOOGLEMAPS_SERVER, $datos, 80 );
- $xml= simplexml_load_string($r[1]);
- unset($r);
- if( !is_object($xml) )
- echo 'Error XML.';
- else
- {
- $latitud= $xml->result->geometry->location->lat;
- $longitud= $xml->result->geometry->location->lng;
- }
- }
- else if( $_GET["data"] && !$_GET["place"] )# entonces si hay latitude y longitud
- {
- if( strstr($_GET["data"], ",") )
- {
- $x= explode( ",", $_GET["data"]);
- $latitud= $x[0];
- $longitud= $x[1];
- }
- else
- echo 'Error data...';
- }
- if( $latitud && $longitud)
- {
- $dimencion= '280x280'; # dimencion de la imagen
- $args= 'zoom=15&size='. $dimencion. '&maptype=roadmap&markers=color:blue|label:S|'. $latitud. ','. $longitud. '&sensor='. GOOGLEMAPS_SENSOR;
- $datos= array( 'GET', GOOGLEMAPS_STATICMAP.$args );
- $r= socket_iodata( GOOGLEMAPS_SERVER, $datos, 80);
- header_imagen( "image/png" );
- echo $r[1];
- }
- else
- echo 'Error Latitud y Longitud';
- }
- else
- echo 'Error Args...';
- ?>
Add Comment
Please, Sign In to add comment