PHP Classes

vsid-2017-08-14.zip

Recommend this page to a friend!

      Very Simple IP Details  >  All threads  >  vsid-2017-08-14.zip  >  (Un) Subscribe thread alerts  
Subject:vsid-2017-08-14.zip
Summary:Google map is not displayed
Messages:8
Author:Alekos Psimikakis
Date:2017-10-20 09:56:56
 

  1. vsid-2017-08-14.zip   Reply   Report abuse  
Picture of Alekos Psimikakis Alekos Psimikakis - 2017-10-20 09:56:56
The class is OK except that the Google map (the hottest feature) is not displayed. The reason is most probably that a personal API key is needed. I know that from Javascript:
src = "https://maps.googleapis.com/maps/api/js?key=[API_key]..."
This must be implemented in your class.

  2. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of zinsou A.A.E.Moïse zinsou A.A.E.Moïse - 2017-10-20 11:57:10 - In reply to message 1 from Alekos Psimikakis
Hi
I'm sorry it has not work for you.As you may see on the package details other user rate the example file 100%.That means that it works fine.I also test it at the moment and it works fine too...So i'm surprised.The package doesn't use a dynamic map from google but a static one so it is just a simple image that must be loaded from googlestatic map .My question is :are you connected when you test it? because i'm sure it works fine...

  3. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of Alekos Psimikakis Alekos Psimikakis - 2017-10-20 18:23:08 - In reply to message 2 from zinsou A.A.E.Moïse
I believe it works for you, of course. Here is what I get when I run 'example.php':

---------------------------------------------------------------
Array
(
[ip] => 66.84.41.158
[hostname] => s158.n41.n84.n66.static.myhostcenter.com
[city] => St. Petersburg
[region] => Florida
[country] => US
[loc] => 27.7723,-82.6341
[org] => AS17054 CONTINENTAL BROADBAND PENNSYLVANIA, INC.
[postal] => 33701
)
St. Petersburg, Florida, US Map
---------------------------------------------------------------

The last string is the image title, which displayed at the place of the image.

OK, API key is not needed for static map images (I just verified this), but I also checked different methods of displaying static ma images at https://www.codexworld.com/google-maps-image-using-google-static-maps-api/. There's one used with PHP and it works. I checked it.

  4. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of zinsou A.A.E.Moïse zinsou A.A.E.Moïse - 2017-10-21 09:57:10 - In reply to message 3 from Alekos Psimikakis
ok.So all you need to do is to replace the line of code in my package by the line that works for you.As it is just a simple image i think this wouldn't be difficult to do for you.I must however underline the fact that ipinfo.io uses the same method as what i use in my code and it works fine too for lot of people that rated the package so i am really surprised that it didn't for you. Did you try to change your browser to be sure?

  5. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of Alekos Psimikakis Alekos Psimikakis - 2017-10-23 11:06:49 - In reply to message 4 from zinsou A.A.E.Moïse
Hi

Thank you for trying to help. It's not a browser problem Both Firefox and IE9 react in a similar way. And this way is erratic! That is sometimes the image is dosplaced and other times not. Once it fails, it can't be displayed by refreshed (rerunning the PHP).
Neither is the method used for obtaining the static Google map image (via address or via latitude&longitude) changes anything.
All these methods work stably (w/o any "miss") when used directly an HTML file (with <img src=...">).

I spent a lot of time trying to finally find out that the problem lies in the 'echo' command! (i.e. echo '<img src="...">';, esp. with this special kind of Google map URLs.)

So what I did was to use your great 'scan()' function to get the array and then from it form the Google map URL, download the image into a buffer and display the image as buffered image!
I know, it's a terrible bypass, but at least displaying a buffered image always works (for me)!



  6. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of zinsou A.A.E.Moïse zinsou A.A.E.Moïse - 2017-10-23 13:52:29 - In reply to message 5 from Alekos Psimikakis
Hi
Nice idea.I'm happy that you finally found a way to use the package...
Could you please give your code here?This way i can add this option to the package for the next release.I'm also actually think about use a package called map builder to make an option for dynamic google map be available in the next release...

  7. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of Alekos Psimikakis Alekos Psimikakis - 2017-10-24 09:08:53 - In reply to message 4 from zinsou A.A.E.Moïse
Here is the code:

$ip = "66.84.41.158";
$myip = new vsipdetails($ip);
$ary = $myip->scan(); $myip->close();

$loc = $ary['loc'];
$zoom = "12"; $size = "600x200";

$img_url = "https://maps.googleapis.com/maps/api/staticmap?center=".$loc."&zoom=".$zoom."&size=".$size;
$buf = file_get_contents($img_url);
echo '<img src="data:image/png;base64,'.base64_encode($buf).'"/>';

(I could also use the address URL method, from $ary['city'] etc., but the location is much more simple.)

  8. Re: vsid-2017-08-14.zip   Reply   Report abuse  
Picture of zinsou A.A.E.Moïse zinsou A.A.E.Moïse - 2017-10-24 09:37:07 - In reply to message 7 from Alekos Psimikakis
Thanks you very much.This would probably help those who had the same issue.Thanks for your feedback.
Regards.