Reverse Geocode In Egmap

Hi all!

I am using EGMap extension, which works fine until i needed to get coordinates from an given address.

I am using the example that is found on the extension page, http://www.yiiframework.com/extension/egmap#hh12

The next code is exactly the same code than the one in the documentation, but the latitude and longitude which are returning is 0,0.




$gMap = new EGMap();

$gMap->setWidth(500);

$gMap->setHeight(400);

$gMap->zoom = 5;

 

$sample_address = 'Czech Republic, Prague, Olivova';

 

// Create geocoded address

$geocoded_address = new EGMapGeocodedAddress($sample_address);

$geocoded_address->geocode($gMap->getGMapClient());

 

// Center the map on geocoded address

 $gMap->setCenter($geocoded_address->getLat(), $geocoded_address->getLng());

 

// Add marker on geocoded address

$gMap->addMarker(

     new EGMapMarker($geocoded_address->getLat(), $geocoded_address->getLng())

);

 

$gMap->renderMap();



I tried changing the address, i am executing it with the Mozilla Firefox Console running and it is telling me NO errors.

So I can not figure out why is happening this…

Has anyone any idea about the reason of this problem?

I will really appreciate any suggestion :rolleyes:

Thank you very much!

Regards!

anyone? please… :unsure:

no idea? :mellow:

I have the same problem. Did you solve it?

First of all, don’t repeat your question or write repeated “answers” like “anyone?”, because this may upset some old users and force them to not answer you. Yes, developers are twixed, evil people! :] We have over 120k users here, even if half of this are spammers or one-time use accounts, it still leave as with 60k developers. And believe me, if someone will be able to help you, he or she will help. Yii Community is in general a very open, friendly group of people (aside of being evil, twixed developers!) :]

[/size]

I have never used Antonio’s EGMap (but I’m willing to do so), so this is purely theoretical and probably dumb suggestion. But there is one thing that concerns me.

Geocoding uses (if I’m not mistaken) a standard query-reply mechanism, based on Javascript, right? So, it have to poll Google servers with your name to get geocoding in response. And yet, you’re trying to use reply in the very same piece of code, where you’re issuing question. Your code is placed in the same controller and action, so your sending to a browser an already expected result. Your Javascript code (which is behind all Google services, if I’m not mistaken) is unable to be run.

I don’t know, if you understand me and if I’m able to express, what I’m thinking. But all the time I’ve been using Google Maps (directly, not via EGMap, and without geocoding) was always Javascript based. So my PHP (Yii) code only generated some Javascript code that actually did a hard job of contanting Google servers (via Ajax) and load back results once page was already returned to browser.

In other word, I don’t know, if you can use geocoding (or Google Maps at all) directly from PHP. I think you have to use Javascript, which requires you to send to the browser only initiating code and handle results (geocoding) there, also via Javascript, not directly form PHP.

But, then again, you’re using an example form extension page, which should work. At least theoretically. So I’m problably very, very wrong and won’t be able to help you. Sorry!

OK, it sound like I’m drunk (which I’m not). Try to read this five times, and maybe you’ll get, what I mean. If not, write again, I’ll try to explain this better tommorow.