|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
eatc7402 Smarty Rookie
Joined: 18 Feb 2008 Posts: 23
|
Posted: Sat Feb 23, 2008 11:25 pm Post subject: Can't print TWO maps on one page w/GoogleMapsAPI 2.5 |
|
|
I am attempting to print TWO maps on the same page using the
GoogleMapsAPI 2.5. I have set up two maps objects and I can get
either one to print but NOT BOTH. I am new to this API for PHP.
HERE is the code I've written.
==================================
Code: |
<?php
require('GoogleMapAPI.class.php');
$map1 = new GoogleMapAPI('map1');
// enter YOUR Google Map Key // for localhost
// for the /php dir
$map1-
>setAPIKey('ABQIAAAAA4K1gFTiRd0xfFgeHzQw0hS2if_gY7iOZx0fI_oIL592_7ROohTAzKfvpCamsCMoQrlzywRIwWEbhw');
$map1->setWidth('500px'); $map1->setHeight('500px');
$map1->enableOverviewControl() ;
$geocode1 = $map1->geoGetCoords('100 Unversity Ave E, St. Paul,
MN');
echo $geocode1['lon'];
echo "<br>" ;
echo $geocode1['lat'];
echo "<br><br>" ;
//$map1->setCenterCoords($geocode1['lon'],$geocode1['lat']) ;
$map1->addMarkerByCoords($geocode1['lon'],
$geocode1['lat'],'test','test');
$map1->setZoomLevel(16);
$map1->setMapType('map');
$map2 = new GoogleMapAPI('map2');
// for the /php di
$map2-
>setAPIKey('ABQIAAAAA4K1gFTiRd0xfFgeHzQw0hS2if_gY7iOZx0fI_oIL592_7ROohTAzKfvpCamsCMoQrlzywRIwWEbhw');
$map2->setWidth('500px'); $map2->setHeight('500px');
$geocode2 = $map2->geoGetCoords('237 S 70th suite 220 Lincoln NE
68510');
echo $geocode2['lon']; echo "<br>" ;
echo $geocode2['lat']; echo "<br><br>" ;
$map2->setCenterCoords($geocode2['lon'],$geocode2['lat']) ;
$map2->addMarkerByCoords($geocode2['lon'],
$geocode2['lat'],'test','test');
$map2->setZoomLevel(14);
?>
<!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 $map1->printHeaderJS(); ?>
<?php //$map2->printHeaderJS(); ?>
<?php $map1->printMapJS(); ?>
<?php //$map2->printMapJS(); ?>
<!-- necessary for google maps polyline drawing in IE -->
<style type="text/css">
v\:* {
behavior:url(#default#VML);
}
</style>
</head>
<body onload="onLoad()">
<body>
<table border=1>
<tr><td><?php $map1->printMap(); ?></td>
<td><?php $map1->printSidebar(); ?>--></td>
</tr>
<tr><td> </td></tr>
</table>
<table border=1>
<tr><td><?php $map2->printMap(); ?></td>
<td><?php $map2->printSidebar(); ?>--></td>
</tr>
</table>
</body>
</html>
|
My problem seems (maybe) to be in the ciode just after the <head>
tag, as in...
Code: |
<?php $map1->printHeaderJS(); ?>
<?php //$map2->printHeaderJS(); ?>
<?php $map1->printMapJS(); ?>
<?php //$map2->printMapJS(); ?> |
This code produces THIS PAGE
http://www.extraalarm.org/php/lib/GoogleMapAPI-2.5/test_teo_maps_01.php
And this code
Code: |
<?php //$map1->printHeaderJS(); ?>
<?php $map2->printHeaderJS(); ?>
<?php //$map1->printMapJS(); ?>
<?php $map2->printMapJS(); ?> |
produces THIS PAGE
http://www.extraalarm.org/php/lib/GoogleMapAPI-2.5/test_teo_maps_02.php
But I cannot seem to figure out the proper way to get the BOTH to
print. There must be a way I just can;t seem to figure it out.
eatc7402 |
|
Back to top |
|
eatc7402 Smarty Rookie
Joined: 18 Feb 2008 Posts: 23
|
Posted: Wed Feb 27, 2008 6:36 am Post subject: Second request |
|
|
SECOND REQUEST.
I would REALLY like to learn how to get more than
one map per page to print.
The only method I can figure out is to have buttons
which call separate php pages in multiple external
windows.
The README file packaged with the API code 'alludes'
to the fact that you print multiple maps on one page,
but no examples of HOW TO DO IT are given. anyone
who knows how, it would be nice to SHARE IT with
all of us who could use the knowledge. Thanks.
firebuff55123 |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Feb 27, 2008 2:56 pm Post subject: |
|
|
It looks like you are going about it the right way:
$map1 = new GoogleMapAPI('map1');
$map2 = new GoogleMapAPI('map2');
That should make two separate instances. Have you tried to make two very simple maps work together first? Are you getting any javascript errors that would help?
I can't say I've ever used two maps one page, so it may very well be that there are problems with it. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Feb 27, 2008 3:25 pm Post subject: |
|
|
I just tested it, and I can see that it just doesn't work.
Although a separate instance of the map object is made, the javascript vars do not have their own namespaces. I'm not sure javascript even has name spaces, so it's likely that the map id will need to be appended to each and every javascript variable created. This will be put in the to-do list for this project. |
|
Back to top |
|
eatc7402 Smarty Rookie
Joined: 18 Feb 2008 Posts: 23
|
Posted: Wed Feb 27, 2008 7:43 pm Post subject: |
|
|
Okay, thanks. I am glad at least that I was kind of in
the 'ballpark' about how it 'should' have worked.
I will look forward to the ability to place more than
map on a page. I already have a desire to do just
such a thing.
eatc7402 |
|
Back to top |
|
|
|
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
|