<?php echo $lat; ?>,
<?php echo $lng; ?>)
我正在尝试使用此页面中的代码使用谷歌在地图上方或下方的页面上获取坐标和 dprint, http: //www.galengrover.com/projects/PHPGoogleMaps-Examples/geolocation.php
我似乎不明白这是如何工作的。
require( '_system/autoload.php' );
$map_options = array(
'map_id' => 'map23',
'draggable' => true,
'center' => 'San Diego, CA',
'height' => '500px',
'width' => '500px',
'zoom' => 16,
'bicycle_layer' => true
);
$map = new \PHPGoogleMaps\Map( $map_options );
//
$marker = \PHPGoogleMaps\Overlay\Marker::createFromUserLocation( array( 'geolocation_high_accuracy' => true, 'geolocation_timeout' => 10000 ) );
$map->addObject( $marker );
// If you want to set geolocation options you must call enableGeolocation() explicitly
// Otherwise it will be called for you when you use geolocation functions
$map->enableGeolocation( 5000, true );
// Set the loading content. This will display while the browser geolocates the user.
$map->setLoadingContent('<div style="background:#eee;height:300px;padding: 200px 0 0 0;text-align:center;"><img src="_images/loading.gif" style="display:block; margin: auto;"><p>Locating you...</p></div>'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ground Overlays -
<?php echo PAGE_TITLE ?>
</title>
<link rel="stylesheet" type="text/css" href="_css/style.css">
<?php $map->printHeaderJS() ?>
<?php $map->printMapJS() ?>
</head>
<body><h1>Geolocation</h1>(
<?php require( '_system/nav.php' ) ?>
<p>This example finds your location and centers the map on it. It also uses map::setLoadingContent() to display a loading message to the user.
</p>
<?php $map->printMap() ?>(
<?php echo $lat; ?>,
<?php echo $lng; ?>)