当前位置: 首页>>代码示例>>PHP>>正文


PHP geocode函数代码示例

本文整理汇总了PHP中geocode函数的典型用法代码示例。如果您正苦于以下问题:PHP geocode函数的具体用法?PHP geocode怎么用?PHP geocode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了geocode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getClosestHub

 function getClosestHub($address, $maxMiles)
 {
     $geocode = geocode($address);
     $longitude = $geocode['longitude'];
     $latitude = $geocode['latitude'];
     $maxMeters = miles2meters($maxMiles);
     return $this->collection->findOne(array('geojson' => array('$near' => array('$geometry' => array('type' => 'Point', 'coordinates' => array($longitude, $latitude)), '$maxDistance' => $maxMeters))));
 }
开发者ID:edwardshe,项目名称:sublite-1,代码行数:8,代码来源:SocialModel.php

示例2: get

 public static function get($location)
 {
     $geocode = self::lookup($location);
     if (!is_null($geocode)) {
         return $geocode;
     }
     $geocode = geocode($location);
     if (is_null($geocode)) {
         return null;
     }
     self::record($location, $geocode);
     return $geocode;
 }
开发者ID:davidliuliuliu,项目名称:sublite,代码行数:13,代码来源:GeocodeModel.php

示例3: geo_town

function geo_town($address, $geocode = null)
{
    if (empty($geocode)) {
        $geocode = geocode($address);
    }
    if (empty($geocode['results'][0]['address_components'])) {
        return false;
    }
    $geocode = $geocode['results'][0]['address_components'];
    foreach ($geocode as $place) {
        if (in_array('locality', $place['types'])) {
            return $place['long_name'];
        }
    }
    return '';
}
开发者ID:m1ke,项目名称:easy-site-utils,代码行数:16,代码来源:map.php

示例4: test_function

function test_function()
{
    $return = $_GET;
    $data_arr = geocode($_GET['street'], $_GET['city'], $_GET['state']);
    if ($data_arr == false) {
        exit("Google geocode api returns ZERO Results: Select correct address");
    }
    $latitude = $data_arr[0];
    $longitude = $data_arr[1];
    $furl = "https://api.forecast.io/forecast/96684c2d23e7643e7c49ecbcfa131e5f/{$latitude},{$longitude}?units={$_GET['degree']}&exclude=flags";
    //error_log($furl, 0);
    $resp_json = file_get_contents($furl);
    // decode the json
    $respjson = json_decode($resp_json, true);
    $return["json"] = json_encode($respjson);
    echo json_encode($return);
}
开发者ID:pankajk83,项目名称:Webtech,代码行数:17,代码来源:index.php

示例5: data

 function data($data)
 {
     $title = clean($data['title']);
     $jobtype = clean($data['jobtype']);
     $deadline = clean($data['deadline']);
     $duration = str2float(clean($data['duration']));
     $startdate = clean($data['startdate']);
     $enddate = clean($data['enddate']);
     $salarytype = clean($data['salarytype']);
     $salary = clean($data['salary']);
     if ($salarytype != 'other') {
         $salary = str2float($salary);
     }
     if ($jobtype == 'fulltime' || $jobtype == 'parttime') {
         $duration = '';
         $enddate = '';
     }
     $company = $data['company'];
     $desc = clean($data['desc']);
     $location = clean($data['location']);
     $locationtype = '';
     if (isset($data['locationtype'])) {
         $locationtype = clean($data['locationtype']);
     }
     $geocode = geocode($location);
     if ($locationtype) {
         $location = '';
         $geocode = '';
     }
     $requirements = clean($data['requirements']);
     $link = clean($data['link']);
     if (!filter_var($link, FILTER_VALIDATE_EMAIL) && !preg_match('`^(https?:\\/\\/)`', $link)) {
         $link = "http://{$link}";
     }
     return array('title' => $title, 'deadline' => $deadline, 'duration' => $duration, 'desc' => $desc, 'geocode' => $geocode, 'location' => $location, 'requirements' => $requirements, 'link' => $link, 'salary' => $salary, 'company' => $company, 'salarytype' => $salarytype, 'startdate' => $startdate, 'enddate' => $enddate, 'jobtype' => $jobtype, 'locationtype' => $locationtype);
 }
开发者ID:edwardshe,项目名称:sublite-1,代码行数:36,代码来源:JobController.php

示例6: isset

//if the form is submitted == if there are post variables
if (!empty($_POST)) {
    // print_r($_POST); // pour debug
    // print_r($_FILES); //for debug too
    // Récupération et traitement des variables du formulaire d'ajout/modification
    //loc_id ; //auto incremented at creation?!
    $loc_name = isset($_POST['loc_name']) ? trim($_POST['loc_name']) : '';
    $loc_adr = isset($_POST['loc_adr']) ? trim($_POST['loc_adr']) : '';
    $loc_city = isset($_POST['loc_city']) ? trim($_POST['loc_city']) : '';
    $loc_cp = isset($_POST['loc_cp']) ? intval(trim($_POST['loc_cp'])) : 0;
    $loc_desc = isset($_POST['loc_desc']) ? trim($_POST['loc_desc']) : '';
    //$loc_img est probablemnt a changer vu qu'on va devoir importer un fichier blob...
    $loc_img = isset($_POST['loc_img']) ? trim($_POST['loc_img']) : '';
    $loctype_typ_id = isset($_POST['loctype_typ_id']) ? intval(trim($_POST['loctype_typ_id'])) : 0;
    // coordonnées latitude & longitude
    $locXY = geocode($_POST['loc_adr'] . "," . $_POST['loc_city']);
    //for uploading image
    if (count($_FILES) > 0) {
        $loc_img = file_get_contents($_FILES['loc_img']['tmp_name']);
    }
    //sql for adding location
    if (!isset($_GET['id'])) {
        $add_loc_sql = "\n\t\tINSERT INTO locations (loc_name,loc_adr ,loc_city ,loc_cp ,loc_desc ,loc_img ,loctype_typ_id, loc_x, loc_y)\n\t\tVALUES (:name,:adr ,:city ,:cp ,:desc ,:img ,:typ_id ,:loc_x ,:loc_y)\n\t\t";
        $pdoStatement = $pdo->prepare($add_loc_sql);
        // Je bind toutes les variables de requête
        $pdoStatement->bindValue(':name', $loc_name);
        $pdoStatement->bindValue(':adr', $loc_adr);
        $pdoStatement->bindValue(':city', $loc_city);
        $pdoStatement->bindValue(':cp', $loc_cp);
        $pdoStatement->bindValue(':desc', $loc_desc);
        $pdoStatement->bindValue(':img', $loc_img);
开发者ID:ocymia,项目名称:Mylph,代码行数:31,代码来源:add_location.php

示例7: geocode

    <style>
	
    #map_canvas{
        width:100%;
        height: 30em;
		}
		

    </style>
 
</head>
<body>
 
<?php 
if ($_GET) {
    $data = geocode($_GET['address']);
    $zoom = $_GET['zoom'];
    if (!$zoom) {
        $zoom = 14;
    }
    $mapaddress = urlencode($_GET['address']);
    $mapurl = "http://[YOUR DOMAIN HERE]/embedmap.php?address={$mapaddress}&zoom={$zoom}";
    // proceeds only if address is geocoded
    if ($data) {
        $latitude = $data[0];
        $longitude = $data[1];
        $address = $data[2];
        ?>
	
    <div id="map_canvas">Geocoding address...</div><br>
    
开发者ID:NKSG,项目名称:traffic-map-embed,代码行数:30,代码来源:embedmap_display.php

示例8: submit

	private function submit($post_data)
	{
		global $db, $template, $config, $user;
		
		
		$license_plate_input = (isset($post_data['license_plate_input'])) ? $post_data['license_plate_input'] : ''; //Errorno 1
		$location_input = (isset($post_data['location_input'])) ? $post_data['location_input'] : ''; //Errorno 2
		$date_input = (isset($post_data['date_input'])) ? explode('-', $post_data['date_input']) : ''; //Errorno 3
		$comments_input = (isset($post_data['comments_input'])) ? $post_data['comments_input'] : 'Geen comment'; //Errorno 4
		$upload_input = (isset($_FILES['photoupload'])) ? $_FILES['photoupload'] : '';
		
		if(get_licenseplate_sidecode($license_plate_input) == false)
		{
			return 1;
		}
		
		$location = geocode($location_input);
		
		if($location == false)
		{
			return 2;
		}
		
		$location_coords = $location[0];
		$location_readable = $location[1];
		
		if(sizeof($date_input) != 3)
		{
			return 3;
		}
		
		$timestamp = mktime(0,0,0,$date_input[1],$date_input[0],$date_input[2]);
		
		if($timestamp == false)
		{
			return 3;
		}
		
		$uploadname = '';
		
		if(!empty($upload_input))
		{
		
			if(!move_uploaded_file($_FILES['photoupload']['tmp_name'], 
			'/home/smartiechick/public_html/roadsterspot/uploads/spots/' . $_FILES['photoupload']['name']))
			{
				return 4;
			}
			else
			{
				$uploadname = $_FILES['photoupload']['name'];
			}
		}
		
        $roadster_id = 0;
        
        $sql = "SELECT * 
        	FROM roadster 
        	WHERE roadster_license_plate = '" . $db->sql_escape($license_plate_input) . "'";
		$result = $db->sql_query($sql);       
		$roadster = $db->sql_fetchrow($result);

		$roadster_id = $roadster['roadster_id'];

		if(empty($roadster))
		{
		    //Add new roadster
		    $sql = "INSERT INTO roadster 
		    	(roadster_license_plate) 
		    	VALUES ('" . $db->sql_escape($license_plate_input) . "')";
			$db->sql_query($sql);
		    
			$roadster_id = $db->sql_nextid();
		    //return 1;
		}
		
		//Add spot to the database
		$sql = "INSERT INTO spots 
			(user_id, roadster_id, spot_coordinates, spot_location_readable, spot_date, spot_comments, spot_photo) 
			VALUES ('" . $user->uid . "',
			'" . $roadster_id . "', 
			'" . $db->sql_escape($location_coords) . "', 
			'" . $db->sql_escape($location_readable) . "', 
			'" . $db->sql_escape($timestamp) . "', 
			'" . $db->sql_escape($comments_input) . "', 
			'" . $db->sql_escape($uploadname) . "')";
		$db->sql_query($sql);
		
		return 0;
	}
开发者ID:Ganonmaster,项目名称:Roadsterspot,代码行数:90,代码来源:home.php

示例9: geocode

        height:30em;
    }
     
    #map-label,
    #address-examples{
        margin:1em 0;
    }
    </style>
 
</head>
<body>
 
<?php 
if (isset($_POST['add'])) {
    // get latitude, longitude and formatted address
    $data_arr = geocode($_POST['res_add']);
    // if able to geocode the address
    if ($data_arr) {
        $latitude = $data_arr[0];
        $longitude = $data_arr[1];
        $formatted_address = $data_arr[2];
        ?>
 
    <!-- google map will be shown here -->
    <div id="gmap_canvas">Loading map...</div>
    <div id='map-label'>Map shows approximate location.</div>
 
    <!-- JavaScript to show google map -->
    <script type="text/javascript" src="http://maps.google.com/maps/api/js"></script>    
    <script type="text/javascript">
        function init_map() {
开发者ID:madhu1995,项目名称:crm,代码行数:31,代码来源:geo.php

示例10: geocode

$area_site = $details["area_site"];
$active_site = $details["active_site"];
// check to see if lat/lng are absent, and if so, geocode the city/state and
// temp store into $lat_site and $long_site so you get a general location pin
// on the map
if ($lat_site == null || $long_site == NULL) {
    // first check for city, state
    if (isset($city_site) && isset($state_site)) {
        $addr = $city_site . ", " . $state_site;
        // otherwise, if area has a value, use that
    } else {
        if (isset($area_site)) {
            $addr = $area_site;
        }
    }
    $coords = geocode($addr);
    // make sure we got a good result
    if ($coords) {
        $lat_site = $coords[0];
        $long_site = $coords[1];
    }
}
if ($active_site > 0 || permissions("Sites") >= 3) {
    //TODO: Indicate if site is inactive
    if ($street_site != NULL) {
        $address = $street_site . ", " . $city_site . ", " . $state_site . " " . $zip_site;
    } else {
        $address = $area_site;
    }
    if ($facilities_site == NULL) {
        $facilities_site = "No information on file";
开发者ID:gleannabhann,项目名称:records,代码行数:31,代码来源:site.php

示例11: Database_Connection

<?php 
if ($_POST) {
    include_once '../Database/Database_Connection.php';
    $databaseConnection = new Database_Connection();
    $databaseConnection->createDatabase();
    $_store_name = $_POST['_store_name'];
    if (!empty($_store_name)) {
        $_store_rating = $_POST['_store_rating'];
        $_store_category = $_POST['_store_category'];
        $_default_address_street = $_POST['_default_address_street'];
        $_default_address_city = $_POST['_default_address_city'];
        $_default_address_state = $_POST['_default_address_state'];
        $_default_address_zip = $_POST['_default_address_zip'];
        $_default_address_country = $_POST['_default_address_country'];
        // get latitude, longitude and formatted address
        $data_arr = geocode($_default_address_street . ',' . $_default_address_city . ',' . $_default_address_state . ',' . $_default_address_zip . ',' . $_default_address_country);
        // if able to geocode the address
        if ($data_arr) {
            $latitude = $data_arr[0];
            $longitude = $data_arr[1];
            $databaseConnection->addStoreInfo($_store_name, $_store_rating, $_store_category, $latitude, $longitude, $_default_address_street, '', $_default_address_city, $_default_address_state, $_default_address_zip, $_default_address_country);
            echo "<script>window.location.reload()</script>";
        } else {
            echo "The address does not exist, please try again!";
        }
    } else {
        $delete_store_name = $_POST['_delete_store'];
        $databaseConnection->deletStoreInfo($delete_store_name);
    }
}
?>
开发者ID:scudsbook,项目名称:project_scudsbook,代码行数:31,代码来源:Database_Store_Manager.php

示例12: spyview

function spyview($from_date = "", $to_date = "", $rows = "999", $spytype = "")
{
    global $wpdb;
    $whereis = "";
    if ($spytype == 'spider') {
        $whereis = " AND spider!=''";
    } elseif ($spytype == 'nospider') {
        $whereis = " AND spider=''";
    } elseif ($spytype == 'spam') {
        $whereis = " AND spam>0";
    } elseif ($spytype == 'nospam') {
        $whereis = " AND spam=0";
    } elseif ($spytype == 'nospamspider') {
        $whereis = " AND spam=0 AND spider=''";
    } elseif ($spytype == 'searchengine') {
        $whereis = " AND searchengine!='' AND search!=''";
    } elseif ($spytype == 'referrer') {
        $whereis = " AND referrer!='' AND referrer NOT LIKE '%{$wpurl}%' AND searchengine='' AND search=''";
    } elseif ($spytype == 'comauthor') {
        $whereis = " AND comment_author!=''";
    } elseif ($spytype == 'loggedin') {
        $whereis = " AND username!=''";
    }
    //check for arguments...
    if (empty($to_date)) {
        $to_date = wassup_get_time();
    }
    if (empty($from_date)) {
        $from_date = $to_date - 5;
    }
    $table_tmp_name = $wpdb->prefix . "wassup_tmp";
    if (function_exists('get_option')) {
        $wassup_settings = get_option('wassup_settings');
    }
    if (!empty($wassup_settings['wassup_screen_res'])) {
        $screen_res_size = (int) $wassup_settings['wassup_screen_res'];
    } else {
        $screen_res_size = 670;
    }
    $max_char_len = $screen_res_size / 10;
    if (function_exists('get_bloginfo')) {
        $wpurl = get_bloginfo('wpurl');
        $siteurl = get_bloginfo('siteurl');
    }
    $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM {$table_tmp_name} WHERE timestamp BETWEEN {$from_date} AND {$to_date} {$whereis} GROUP BY id ORDER BY max_timestamp DESC");
    if (!empty($qryC)) {
        //restrict # of rows to display when needed...
        $row_count = 0;
        //display the rows...
        foreach ($qryC as $cv) {
            if ($row_count < (int) $rows) {
                $timestamp = $cv->max_timestamp;
                $ip = @explode(",", $cv->ip);
                if ($cv->referrer != '') {
                    if (!eregi($wpurl, $cv->referrer) or $cv->searchengine != "") {
                        if (!eregi($wpurl, $cv->referrer) and $cv->searchengine == "") {
                            $referrer = '<a href="' . $cv->referrer . '" target=_"BLANK"><span style="font-weight: bold;">' . stringShortener($cv->referrer, round($max_char_len * 0.8, 0)) . '</span></a>';
                        } else {
                            $referrer = '<a href="' . $cv->referrer . '" target=_"BLANK">' . stringShortener($cv->referrer, round($max_char_len * 0.9, 0)) . '</a>';
                        }
                    } else {
                        $referrer = __('From your blog', 'wassup');
                    }
                } else {
                    $referrer = __('Direct hit', 'wassup');
                }
                // User is logged in or is a comment's author
                if ($cv->username != "") {
                    $unclass = "-log";
                    $map_icon = "marker_loggedin.png";
                } elseif ($cv->comment_author != "" and $cv->username == "") {
                    $unclass = "-aut";
                    $map_icon = "marker_author.png";
                } elseif ($cv->spider != "") {
                    $unclass = "-spider";
                    $map_icon = "marker_bot.png";
                } else {
                    $map_icon = "marker_user.png";
                }
                // Start getting GEOIP info
                $geo_url = "http://api.hostip.info/get_html.php?ip=" . $ip[0] . "&position=true";
                $data = file($geo_url);
                if (eregi("unknown", $data[0])) {
                    $loc_country = eregi_replace("country: ", "", $data[0]);
                }
                if (eregi("unknown", $data[1])) {
                    $loc_city = eregi_replace("city: ", "", $data[1]);
                }
                $geoloc = $loc_country . " " . $loc_city;
                if ($wassup_settings['wassup_geoip_map'] == 1) {
                    $gkey = $wassup_settings['wassup_googlemaps_key'];
                    if ($geoloc != "") {
                        $geocode = geocode($geoloc, $gkey);
                        if ($geocode[0] != 200) {
                            $lat = explode(":", $data[2]);
                            $lat = $lat[1];
                            $lon = explode(":", $data[3]);
                            $lon = $lon[1];
                        } else {
                            $lat = $geocode[2];
//.........这里部分代码省略.........
开发者ID:alx,项目名称:alexgirard.com-blog,代码行数:101,代码来源:main.php

示例13: switch

switch ($task2) {
    case 'savecoord':
        savecoord();
        jexit();
        break;
    case 'saveaddress':
        saveaddress();
        jexit();
        break;
    case 'getlistings':
        $count = JRequest::getInt('count', 25);
        getlistings($count);
        jexit();
        break;
    default:
        geocode();
}
function savecoord()
{
    $db =& JFactory::getDBO();
    $link_ids = JRequest::getVar('link_id', array(), 'post');
    JArrayHelper::toInteger($link_ids, array(0));
    $lats = JRequest::getVar('lat', array(), 'post');
    $lngs = JRequest::getVar('lng', array(), 'post');
    $coordinates = array();
    $done_link_ids = array();
    if (empty($link_ids)) {
        echo '';
    } else {
        foreach ($link_ids as $link_id) {
            if ($lats[$link_id] && !empty($lats[$link_id]) && $lngs[$link_id] && !empty($lngs[$link_id])) {
开发者ID:rsemedo,项目名称:Apply-Within,代码行数:31,代码来源:geocode.mtree.php

示例14: connect

* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require 'header.php';
require 'navbar.php';
$address = $_POST['address'];
$db = connect();
$geo_var = geocode($address);
$latitude = $geo_var[0];
$longitude = $geo_var[1];
$city = $geo_var[2];
$api_results = get_api_results($latitude, $longitude);
$insert_api_results = insert_api_results($db, $api_results);
$pop_var = populate_variables($db, $latitude, $longitude);
function page_title()
{
    $title = 'Heatery';
    if (isset($title) && is_string($title)) {
        print_r($title);
    } else {
        print_r('Circle Squared Data Labs');
    }
}
开发者ID:heatery,项目名称:maps,代码行数:31,代码来源:functions.php

示例15: message

echo $pop3->numMsg() . " message(s) in mailbox\n";
// print message headers
if ($pop3->numMsg() > 0) {
    for ($x = 1; $x <= $pop3->numMsg(); $x++) {
        $hdrs = $pop3->getParsedHeaders($x);
        print_r($hdrs);
        //echo $hdrs['From'] . "\n" . $hdrs['Subject'] . "\n" . $hdrs['Message-Id'] . "\n\n";
        $count = 0;
        // Only process emails from xxx.
        //        if (preg_match('/evoldir\@evol.biology.mcmaster.ca/', $pop3->getBody($x)))
        if (preg_match('/evoldir\\@evol.biology.mcmaster.ca/', $hdrs['From'])) {
            $id = store_message($hdrs, $pop3->getBody($x));
            if ($id != '') {
                // It's a new message
                // geocode
                $latlng = geocode($pop3->getBody($x));
                if ($latlng) {
                    print_r($latlng);
                    store_latlng($id, $latlng);
                }
                // generate Tinyurl
                $url = 'http://tinyurl.com/api-create.php?url=http://bioguid.info/services/evoldir/get.php?id=' . $id;
                $tiny = get($url);
                $status = $hdrs['Subject'] . ' ' . $tiny;
                echo $status . "\n";
                // Send message to twitter
                if ($config['oauth']) {
                    $parameters = array('status' => $status);
                    $status = $connection->post('statuses/update', $parameters);
                    print_r($status);
                } else {
开发者ID:rdmpage,项目名称:bioguid,代码行数:31,代码来源:pop.php


注:本文中的geocode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。