我如何检索首都或经度和纬度,因为那是 openweathermap 接受的并且我只有国家名称?

How do i retrive capital city or longitude and latitude because that's what openweathermap accepts and i only have country names?

我是 运行 一个使用 openweather-bundle 生成天气数据和统计数据的 symfony 3.4 项目,我想按国家名称搜索,但 API 似乎不支持,所以我进退两难了。

想到的唯一解决方案是使用 JavaScript 获取纬度和经度,但我不知道如何在控制器中处理它

这是我的控制器

public function PaysMeteoAction($name)
{
    $em = $this->getDoctrine()->getManager();
    $pays = $em->getRepository("AppBundle:Pays")->findOneBy(array('name' => $name));
    $openWeather = $this->get('dwr_open_weather');
    $weather = $openWeather->setType('Weather')->getByCityName('London');

    return $this->render('DwrOpenWeatherBundle:Default:weather-basic-large.html.twig', array(
        'weather' => $weather,
        'pays' => $pays,
    ));
}

twig是bundle默认提供的,我的路线如下

pays_meteo:
    path:     /meteo/{name}
    defaults: { _controller: "ExperienceBundle:Pays:PaysMeteo" }

我只需要将大写字母插入数据库即可。