<?php

$request = 'http://www.tritonetech.com/php_uploads/rnd/location_try.php?option=2';
$json = file_get_contents($request);
function json_code($json)
{
    //remove curly brackets to beware from regex errors
    $json = substr($json, strpos($json, '{') + 1, strlen($json));
    $json = substr($json, 0, strrpos($json, '}'));
    $json = preg_replace('/(^|,)([\\s\\t]*)([^:]*) (([\\s\\t]*)):(([\\s\\t]*))/s', '$1"$3"$4:', trim($json));
    return json_decode('{' . $json . '}', true);
}
//echo "<pre>";
$convertedtoarray = json_code($json);
//print_r($convertedtoarray);
$latitude[] = $convertedtoarray['latitude'];
print_r($latitude);
$longitude[] = $convertedtoarray['longitude'];
print_r($longitude);
$count = '1';
function geoCodeYp($point)
{
    // Replace your Yahoo AppID here
    $yahoo_appid = '_18CdmHV34HjeW_rXezIti6jhypsfSqMmAlFFGIOPWC1DW3p0CXYU9eaoL.COp0-';
    //URLEncode for eg convert space to %20 .
    $pointenc = urlencode($point);
    // URL Formation that will fetch you the results on query
    $url = "http://where.yahooapis.com/geocode?location=" . $pointenc . "&gflags=R&appid=" . $yahoo_appid . "&flags=J";
    // get the contents of the URL formed
    $jsondata = file_get_contents($url);
    $json_data = '{
  a: 1,
  b: 245,
  c with whitespaces: "test me",
  d: "function () { echo \\"test\\" }",
  e: 5.66
  }';
    $coord = explode(" ", $point);
    // this will json encode the data .
    $convertedtoarray = json_code($jsondata);
    // line1 of addrress comprising of house,street no etc
    // line 2 of address comprising of city state country
    $line1 = $convertedtoarray['ResultSet']['Results']['0']['line1'];
    $line2 = $convertedtoarray['ResultSet']['Results']['0']['line1'];
    $county = $convertedtoarray['ResultSet']['Results']['0']['county'];
    $street = $convertedtoarray['ResultSet']['Results']['0']['street'];
    if ($line1 == "" || $line2 == "" || $county == "" || $street == "") {
        $yahooresults['status'] = "noresult";
    } else {
        $countrycode = $convertedtoarray['ResultSet']['Results']['0']['countrycode'];
        $statecode = $convertedtoarray['ResultSet']['Results']['0']['statecode'];
        $city = $convertedtoarray['ResultSet']['Results']['0']['city'];
        $house = $convertedtoarray['ResultSet']['Results']['0']['house'];
        $latitude = $convertedtoarray['ResultSet']['Results']['0']['latitude'];
        $longitude = $convertedtoarray['ResultSet']['Results']['0']['longitude'];
        $yahooresults = array('countrycode' => $countrycode, 'statecode' => $statecode, 'county' => $county, 'city' => $city, 'street' => $street, 'house' => $house, 'lat' => $latitude, 'lng' => $longitude, 'formatted_address' => $line1 . ' ' . $line2);
    }
    return $yahooresults;
}
Esempio n. 3
0
<?php

// This function will convert a "normal" json to an array.
function json_code($json)
{
    //remove curly brackets to beware from regex errors
    $json = substr($json, strpos($json, '{') + 1, strlen($json));
    $json = substr($json, 0, strrpos($json, '}'));
    $json = preg_replace('/(^|,)([\\s\\t]*)([^:]*) (([\\s\\t]*)):(([\\s\\t]*))/s', '$1"$3"$4:', trim($json));
    return json_decode('{' . $json . '}', true);
}
$json_data = '{ 
      a: 1, 
      b: 245, 
      c with whitespaces: "test me", 
      d: "function () { echo \\"test\\" }", 
      e: 5.66 
   }';
$jarr = json_code($json_data);
  <body onunload="GUnload()">

   <div id="map" style="width: 1000px; height: 550px; margin:0 auto;">
	<!--<?php 
$request = 'http://www.tritonetech.com/php_uploads/rnd/location.php?option=2';
$json = file_get_contents($request);
$jsondata = file_get_contents($request);
function json_code($json)
{
    //remove curly brackets to beware from regex errors
    $json = substr($json, strpos($json, '{') + 1, strlen($json));
    $json = substr($json, 0, strrpos($json, '}'));
    $json = preg_replace('/(^|,)([\\s\\t]*)([^:]*) (([\\s\\t]*)):(([\\s\\t]*))/s', '$1"$3"$4:', trim($json));
    return json_decode('{' . $json . '}', true);
}
print_r(json_code($json));
?>
--></div>
<!--www.tritonetech.com/php_uploads/rnd/Gmap_try.php?uid=&date=-->


    <script type="text/javascript">
    if (GBrowserIsCompatible()) {

	

     var boy = new GIcon();
         boy.image="user.png"
         boy.iconSize=new GSize(32,18);
         boy.iconAnchor=new GPoint(16,9);