Google Maps API PHP客户端 - 创建功能

时间:2014-08-05 01:21:53

标签: php google-maps google-api google-api-php-client

我无法使用Google Maps API PHP客户端创建功能。 我不知道在哪里设置坐标。

我的代码:

$tableID = "xxxx";
$postBody = new Google_Service_MapsEngine_FeaturesBatchInsertRequest();

$feature = new Google_Service_MapsEngine_Feature();
$feature->setType("Feature");

$geometry = new Google_Service_MapsEngine_GeoJsonGeometry();
$geometry->setType("Point");
$point = new Google_Service_MapsEngine_GeoJsonPoint();
$coordinates = "[86.9253,27.9881]"; 
$point->setCoordinates($coordinates);

$feature->setGeometry($geometry);

$properties =  array("gx_id" => "804940557", "mountain_name" => "Mt Everest", "height" => "8848");
$feature->setProperties($properties);

$postBody->setFeatures(array($feature));


$postBody->setFeatures(array($feature));

$service->tables_features->batchInsert($tableID, $postBody);

1 个答案:

答案 0 :(得分:0)

我不确定这一点。官方文档中有关于CURL和JSON的所有内容。但通过我对github的快速分析,我猜是这样的: $feature->setGeometry(array("geometry" => array("type" => "Polygon","coordinates"=>"[86.9253,27.9881]")));

OR

$feature->setGeometry(array("type" => "Polygon","coordinates"=>"[86.9253,27.9881]"));