M
M
Magaram of Agatsarsky2015-03-19 12:40:40
Google Maps
Magaram of Agatsarsky, 2015-03-19 12:40:40

How to get coordinates of regions using php using goole geocoder?

Hello dear colleagues!
I'll do without preludes. In general, the essence of the question is this:
we are trying to calculate the coordinates of cities in a cycle through google, so that later we can drive them into the database so that each settlement in the world corresponds to its coordinate (this is necessary in order to dynamically change the location of the map depending on the selected region).
So, everything works when it happens not in a cycle (1 way). And when we try to get the coordinates in the loop (2nd method), it does not give anything, although this is elementary, the standard procedure.
The code snippets are as follows:
class SiteConfig extends Eloquent{
public static function getLocation($location){
$simple=simplexml_load_file(" maps.googleapis.com/maps/api/geocode/xml?address=".$location."&sensor=true");
return $simple->result->geometry->location;
}
}
//1
Route::get("/test",function(){
$loc=SiteConfig:: getLocation("Moscow");
return $loc;
});
//2
Route::get("/test2",function(){
$c='';
$i=1;
while($i<100){
$c.=var_dump(SiteConfig::getLocation("Moscow"));
}
return $c;
});
Everything works in the first case!
But it doesn't work in the second case.
Site on Laravel - fond.mosco-web.com

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Magaram Agatsarski, 2015-03-19
@magaram

Thanks, but not much. We needed Google.

P
Peter, 2015-03-19
@petrtr

while($i<100){
$c.=var_dump(SiteConfig::getLocation("Moscow"));
$i++;
}
otherwise don't wait

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question