Jump to:
| Project: | GMap Module |
| Version: | 6.x-1.0-rc2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I am trying to duplicate our site: http://www.wimaxmaps.org inside of drupal. I decided to import all of my data into drupal using a node import module and I moved my data into the fields provided by the Gmap/location module. Then after playing around I realized that I couldn't immediately mimic the functionality of the map here: http://www.wimaxmaps.org. So I decided to hand code my map but still pull the data out of my drupal database.
My first hurdle is how do I pull the api key from the gmap module into my custom template?
I have this so far:
<?php include $_SERVER['DOCUMENT_ROOT'] . '/apikey.php'; ?>*/
at the top of my template, above the DOCTYPE and I haev the apikey.php file on my server and I do believe that drupal is detecting it. The problem is, is that I think it thinks I'm trying to use the same API key for two sites. It keeps asking me to get a new api key.
So I looked through the gmap module code and found this:
<?php
function gmap_get_key() {
$key = variable_get('googlemap_api_key', '');
if (module_exists('keys_api')) {
$key = keys_api_get_key('gmap', $_SERVER['HTTP_HOST']);
}
return $key;
}
?>I'm not great at php but I tried placing this in my template and I got this error:
Fatal error: Cannot redeclare gmap_get_key() (previously declared in /home/oursite/beta.wimaxmaps.org/sites/all/modules/gmap/gmap.module:1416) in /home/oursite/beta.wimaxmaps.org/sites/all/themes/custom/wimax_lite/page-node-3174.tpl.php on line 85
So, is there a way I can modify the above code to detect the api code I have put into the gmap module ?
thanks for any input,
Becky
Comments
#1
Hi Becky,
gmap_get_key() is already defined in gmap.module. When you try and add the function definition to your theme, php is crying because suddenly there are 2 versions of one function and it cant tell which one to use.
Instead of defining the function again you should be calling it like this:
<?php print gmap_get_key();?>That will print your API key in the location you need it.
You could also look into the function gmap_simple_map() which is at the end of gmap.module. I've never used it but it's description says it's a simple way to draw a map within a theme.
Cheers,
Sam.
#2
I tried using teh function gmap_simple_map and it worked and didn't work at the same time. I had two big errors with it
.
This was my code:
<?php$lat = $location [latitude];
$long = $location [longitude];
print gmap_simple_map($lat, $long, 'Big Red', '', 7, '600px', '700px', FALSE,''); ?>
and when I tried to implement it i got the error: Request for invalide Marker set Big Red! Error. I read the threads about this problem but nothing worked to resolve it for me.
Also the hight and width of my map effected the size of my info windows on my Node location page, which is provided by the location module!
I wasn't sure whether to post about that here or there. It made them huge.
Any suggestions?
Becky
ps. thank you for the help on the API key thing.