Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

GoogleMapAPI problems - no map images shown

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
kimusan
Smarty n00b


Joined: 29 Sep 2006
Posts: 4

PostPosted: Fri Sep 29, 2006 9:02 pm    Post subject: GoogleMapAPI problems - no map images shown Reply with quote

Hi
I am trying to add a simple map to my homepage, but noting shows up on the map. The frame, controls etc are there, but the background is just grey (no maps).
You can see for yourself here:
www.schulz.dk/getmap.php

The code is the one from the example on the homepage, except that I have disabled the DSN since my webhotel does not support PEAR.
And ofcause I am using my own google api key.

Any ideas on what is wrong?
Back to top
View user's profile Send private message
DerrickBB
Smarty n00b


Joined: 29 Sep 2006
Posts: 1

PostPosted: Fri Sep 29, 2006 11:00 pm    Post subject: Reply with quote

I had the same problem and here's how I worked around it. I am using the following code from the API page.



Code:
<?php
    require('GoogleMapAPI.class.php');

    // pass yahoo app id (something unique) if you are using the
    // YAHOO lookup service, which is default
    $map = new GoogleMapAPI('map');
    // setup database for geocode caching
    $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');
    // enter YOUR Google Map Key
    $map->setAPIKey('YOURGOOGLEMAPKEY');
   
    // create some map markers
    $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','<b>PJ Pizza</b>');
    $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','<b>Old Chicago</b>');
    $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","<b>Valentino's</b>");
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
    <?php $map->printHeaderJS(); ?>
    <?php $map->printMapJS(); ?>
    <!-- necessary for google maps polyline drawing in IE -->
    <style type="text/css">
      v\:* {
        behavior:url(#default#VML);
      }
    </style>
    </head>
    <body onload="onLoad()">
    <table border=1>
    <tr><td>
    <?php $map->printMap(); ?>
    </td><td>
    <?php $map->printSidebar(); ?>
    </td></tr>
    </table>
    </body>
    </html>


Find:


Code:
  // setup database for geocode caching
    $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');


And comment out:


Code:
  // setup database for geocode caching
   // $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');



Next I created a page called conn.php which simply connects to the datbase.

Code:
$conn = mysql_connect (localhost,USERNAME,PASSWORD) or die ("Could not connect");
mysql_select_db(DBNAME,$conn) or die ("Could not select DB");


Now go to the class file around line 360 and change the function to this:

Code:
    function setDSN($dsn) {
        $this->dsn = $dsn;   
      include('conn.php');
    }


All my files are in the same directory so set yours up as needed. This works fine for me.

Hope this helps,
Derrick
Back to top
View user's profile Send private message
kimusan
Smarty n00b


Joined: 29 Sep 2006
Posts: 4

PostPosted: Sat Sep 30, 2006 7:39 am    Post subject: Reply with quote

unfortunately that didn't help for me.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Sep 30, 2006 1:47 pm    Post subject: Reply with quote

Code:
Fatal error: Call to undefined function: is_a() in /mnt/web_dk/web_domains/schulz.dk/public_html/DB.php on line 590
Back to top
View user's profile Send private message Visit poster's website
kimusan
Smarty n00b


Joined: 29 Sep 2006
Posts: 4

PostPosted: Sat Sep 30, 2006 2:00 pm    Post subject: Reply with quote

yep stopped working on it in the middle of the test. If I comment out the setDSN line, then this error will disappear.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Sep 30, 2006 3:17 pm    Post subject: Reply with quote

google is your friend.

Quote:
I'm getting a 'Call to undefined function: is_a()' error

If you are using a PHP version prior to PHP 4.2.0 you should consider updating to PHP 4.3.10 or higher, this will fix the problem. An alternative solution is to install the PEAR package PHP_Compat.
Back to top
View user's profile Send private message Visit poster's website
kimusan
Smarty n00b


Joined: 29 Sep 2006
Posts: 4

PostPosted: Sat Sep 30, 2006 9:46 pm    Post subject: Reply with quote

ahh that explains it. webhotel has planned to upgrade php, but probably not for the next month or so.
Back to top
View user's profile Send private message
ideo3
Smarty n00b


Joined: 10 Oct 2006
Posts: 2

PostPosted: Tue Oct 10, 2006 9:23 am    Post subject: Re: GoogleMapAPI problems - no map images shown Reply with quote

Same problem

.. .any solutions?

Thanks, Thomas


kimusan wrote:
Hi
I am trying to add a simple map to my homepage, but noting shows up on the map. The frame, controls etc are there, but the background is just grey (no maps).
You can see for yourself here:
www.schulz.dk/getmap.php

The code is the one from the example on the homepage, except that I have disabled the DSN since my webhotel does not support PEAR.
And ofcause I am using my own google api key.

Any ideas on what is wrong?
Back to top
View user's profile Send private message
ideo3
Smarty n00b


Joined: 10 Oct 2006
Posts: 2

PostPosted: Tue Oct 10, 2006 9:25 am    Post subject: Help Reply with quote

I've the same problem... but my code doesn't work... any solutions?

www.ideogroup.it/concept/casa/12345/test.php

Thanks,
Thomas

DerrickBB wrote:
I had the same problem and here's how I worked around it. I am using the following code from the API page.



Code:
<?php
    require('GoogleMapAPI.class.php');

    // pass yahoo app id (something unique) if you are using the
    // YAHOO lookup service, which is default
    $map = new GoogleMapAPI('map');
    // setup database for geocode caching
    $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');
    // enter YOUR Google Map Key
    $map->setAPIKey('YOURGOOGLEMAPKEY');
   
    // create some map markers
    $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','<b>PJ Pizza</b>');
    $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','<b>Old Chicago</b>');
    $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","<b>Valentino's</b>");
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
    <?php $map->printHeaderJS(); ?>
    <?php $map->printMapJS(); ?>
    <!-- necessary for google maps polyline drawing in IE -->
    <style type="text/css">
      v\:* {
        behavior:url(#default#VML);
      }
    </style>
    </head>
    <body onload="onLoad()">
    <table border=1>
    <tr><td>
    <?php $map->printMap(); ?>
    </td><td>
    <?php $map->printSidebar(); ?>
    </td></tr>
    </table>
    </body>
    </html>


Find:


Code:
  // setup database for geocode caching
    $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');


And comment out:


Code:
  // setup database for geocode caching
   // $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');



Next I created a page called conn.php which simply connects to the datbase.

Code:
$conn = mysql_connect (localhost,USERNAME,PASSWORD) or die ("Could not connect");
mysql_select_db(DBNAME,$conn) or die ("Could not select DB");


Now go to the class file around line 360 and change the function to this:

Code:
    function setDSN($dsn) {
        $this->dsn = $dsn;   
      include('conn.php');
    }


All my files are in the same directory so set yours up as needed. This works fine for me.

Hope this helps,
Derrick
Back to top
View user's profile Send private message
ezar
Smarty n00b


Joined: 22 Oct 2006
Posts: 2

PostPosted: Sun Oct 22, 2006 12:22 am    Post subject: error with insert code Reply with quote

For solve this you need to change this:

Code:
$_res =& $_db->query('insert into ? values (?, ?, ?)', array($this->_db_cache_table, $address, $lon, $lat));


for this:
Code:
        $_sth =& $_db->prepare('insert into '.$this->_db_cache_table.' values (?, ?, ?)');
        $_db->execute($_sth, array($address, $lon, $lat));


in GoogleMapsAPI.class.php
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Oct 22, 2006 5:42 pm    Post subject: Re: error with insert code Reply with quote

ezar wrote:
For solve this you need to change this:

Code:
$_res =& $_db->query('insert into ? values (?, ?, ?)', array($this->_db_cache_table, $address, $lon, $lat));


for this:
Code:
        $_sth =& $_db->prepare('insert into '.$this->_db_cache_table.' values (?, ?, ?)');
        $_db->execute($_sth, array($address, $lon, $lat));


in GoogleMapsAPI.class.php


fixed in CVS thanks.
Back to top
View user's profile Send private message Visit poster's website
ronberry
Smarty n00b


Joined: 10 Oct 2007
Posts: 3

PostPosted: Fri Oct 12, 2007 3:00 pm    Post subject: can't connect to database Reply with quote

Please correct me if I'm wrong but won't commenting out this code stop the script from looking for the address in the database?:

// setup database for geocode caching
// $map-&gt;setDSN('mysql://USER:PASS@localhost/GEOCODES');


For some reason, even though I followed DerrickBB's coding, I cannot connect to the database. &quot;DB Error: not found&quot; - Does this message tell me
the PEAR db module is working?

PEAR.php &amp; DB.php were uploaded to my www directory and my host has just informed me that they installed the entire db package.

The script works if I comment out the $map-&gt;setDSN... line but does not insert info into the database.

My host tells me I cannot use this code to connect to the db:

mysql://USER:PASS@localhost/GEOCODES

Is there an alternative without reworking entire blocks of code?

Thanks

Ron


Last edited by ronberry on Wed May 05, 2010 10:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
prchakal
Smarty n00b


Joined: 20 Oct 2007
Posts: 2

PostPosted: Sat Oct 20, 2007 9:39 pm    Post subject: The same problem Reply with quote

I have the same problem using the APi 2.5.

Sad

Please help me too in my post:

http://www.phpinsider.com/smarty-forum/viewtopic.php?p=45474
Back to top
View user's profile Send private message
moosus
Smarty n00b


Joined: 12 Feb 2008
Posts: 1

PostPosted: Tue Feb 12, 2008 1:26 am    Post subject: Reply with quote

Just a quick not to say thanks guys ... after pulling my hair out for a while I found this thread and it solved most of my problems.

Thanks for this class

Cheers
moosus
Back to top
View user's profile Send private message
eatc7402
Smarty Rookie


Joined: 18 Feb 2008
Posts: 23

PostPosted: Mon Feb 18, 2008 6:34 am    Post subject: Reply with quote

Well, I'm kind of at a rock and a hard place. I'm attempting to use the
GoogleMapAPI.class.php for the first time. Using the sample code provided in the readme file in the distribution package. with all my test files in the same dir. When I attempt to preview it
in my Rapid PHP editor (which works fine on all other php files) all I get for output is the RAW CODE instead of anything else... like this...
Code:
setDSN('mysql://USER:PASS@localhost/GEOCODES'); // enter YOUR Google Map Key $map->setAPIKey('YOURGOOGLEMAPKEY'); // create some map markers $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','PJ Pizza'); $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','Old Chicago'); $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","Valentino's"); ?>  printHeaderJS(); ?>  printMapJS(); ?>
printMap(); ?>    printSidebar(); ?>


I don't understand this, or why?

I must be doing something wrong, or have something incorrectly installed. But what?

eatc7402
[/code]
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP