地理编码范围Google Maps API

时间:2017-03-08 21:48:30

标签: javascript google-maps google-maps-api-3 google-maps-api-2 google-geocoder

console.log提供了未定义的coord值。如果我们在if函数中使用console.log coord,它会给出值,但似乎值不能从地理编码函数中输出。

有谁知道地理编码的范围是什么?如何更改以从地理编码功能中获取值?

感谢

<?php
error_reporting(E_ALL & ~E_NOTICE);
session_start();
include("blog.php");


$posts = (isset($_GET['id'])) ? get_posts($_GET['id']) : get_posts();
$username = $_SESSION['username'];



?>
<html lang="en">

    <head>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Home</title>
		
		
        <!-- CSS -->
		<link href="accountCSS/myaccountStyle.css" type="text/css" rel="stylesheet">
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
        <link rel="stylesheet" href="indexCSS/bootstrap.min.css">
        <link rel="stylesheet" href="indexCSS/font-awesome.min.css">
		<link rel="stylesheet" href="indexCSS/form-elements.css">
        <link rel="stylesheet" href="indexCSS/style.css">
		
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

        <!-- Favicon and touch icons -->
        <link rel="icon" href="images/favicon.gif">

    </head>

    <body>
	

		<a href="www.cookeh.org"><img src="images/logo.gif" id="logo"/></a>
	<header class="mainheader">
		<nav><ul>
		
			
			<?php
			if(isset($_SESSION['user_id'])){
				echo '<li><a href="logout">Log out</a></li>';
				}else{
				echo '<li><a href="login">Log in</a></li>';
				}
			?>
			<li><a href="myaccount">My Account</a></li>
			<li><a href="contact">Contact</a></li>
			<li><a href="#">Play</a></li>
			<li><a href="index">Home</a></li>
		
		</ul></nav>
		
	</header>

	<h2 class="newsClass"> Recent News <?php if(getPermissions($username)) {echo '<a href="add_post.php", style="color:green">New Post</a>'; }?>
</h2>       
			<?php
					
					foreach($posts as $post) {
						
						?>
        <!-- Top content -->
        <div class="top-content">
        	
            <div class="inner-bg">
                <div class="container">
           
                    <div class="row">
                        <div class="col-sm-6 col-sm-offset-3 form-box">
                        	<div class="form-top">
                        		<div class="form-top-left">
	        

						<h2 class ="title"><a href="index.php?id=<?php echo $post['post_id'];?>" style="color:white"><?php echo $post['title'];?></a></h2>
						<p> Posted on <?php echo date('d-m-Y h:i:s', strtotime($post['date_posted'])); ?>
							in <a href="category.php?id=<?php echo $post['category_id']; ?>", style="color:green"><?php echo $post['name']; ?></a>
						
					
							<br></br>

         			
							
						<?php
						
						if(getPermissions($username)) {
							
							?>
							
					    <a href="edit_post.php?id=<?php echo $post['post_id']; ?>", style="color:green">Edit Post |</a>
							

						<a href="delete_post.php?id=<?php echo $post['post_id']; ?>", style="color:green"> Delete Post</a>
							
						<?php
						}
						?>
						</p>
						<div class="contents"> <?php echo nl2br($post['contents']); ?></div>
						
						

						<?php
					}
					
					?>
                        		</div>
                        		<div class="form-top-right">
                        			
                        		</div>
                            </div>

                        </div>
                    </div>
              
                </div>
            </div>
            
        </div>

        <!-- Javascript -->
        <script src="assets/js/jquery-1.11.1.min.js"></script>
        <script src="assets/bootstrap/js/bootstrap.min.js"></script>
        <script src="assets/js/jquery.backstretch.min.js"></script>
        <script src="assets/js/scripts.js"></script>
        
        <!--[if lt IE 10]>
            <script src="assets/js/placeholder.js"></script>
        <![endif]-->
	
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

	  ga('create', 'UA-88077370-1', 'auto');
	  ga('send', 'pageview');

	</script>
    </body>

</html>

1 个答案:

答案 0 :(得分:2)

在地理编码器回调函数中尝试使用console.log。 在您的代码中,console.log在您收到地理编码响应之前执行。