Help with Google Maps

24 posts by 9 authors in: Forums > CMS Builder
Last Post: January 20, 2010   (RSS)

By ross - February 27, 2009

Hi John

From what I can tell, your code looks fine. It's hard for me to fully test it of course. I was curious if the map itself is at least showing up. If it is, do you get any points at all? Or do only a few show up? And finally, are you getting any Javascript error message popups?

Could you perhaps post a link to the page on your site? I'd like to see the HTML that is being generated.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Help with Google Maps

By blind2uriz - February 27, 2009

The page is just blank. No javascript error. Here is the link to the page:

http://www.idsitepreview.com/map.php

Here is the page I want it on:

http://www.idsitepreview.com/listingDetail.php

I made an iframe in the bottom right of the page where I want the map to show up.
Let me know if you need anything else. Thanks for the reply.

John
John C. Morris
Interdimensional Designs
www.covdesigns.com

By ross - February 27, 2009

Hi John

Thanks!

I viewed the source on map.php page and it looks like the latitude and longitude aren't coming through properly. If you view source on map.php, you'll see:

var point = new GLatLng(,);

Could you double check that you are using the correct variables? The line of code that creates that is:

var point = new GLatLng(<?php echo $listingRecord['latitude'] ?>,<?php echo $listingRecord['longitude'] ?>);

Let me know how you make out :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Help with Google Maps

By blind2uriz - February 27, 2009

Thanks for the info. Yeah I noticed the LatLng wasn't showing up when viewing the source. I'm not at home right now but will be in a few hours, I'll check it and get back with you. Thanks again.

John
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [ross] Help with Google Maps

By blind2uriz - February 27, 2009

ok i came home and I had that line in the var point= correct. Anyway, I decided just to be easier, I scratched that and made a whole new map section w/ text fields for lat and long. I output the php and set up the map.php. Put everything in the correct manner again and it still won't work. I get this error:

Notice: Undefined variable: listingRecords in /home/content/g/r/e/greenways1/html/map.php on line 43

Warning: Invalid argument supplied for foreach() in /home/content/g/r/e/greenways1/html/map.php on line 43

Here's my source from the map.php page:

<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzWpdtAJy15_mFvJb9uOTTxSpUoc7Yr5GTKWfF5EG52h_OrBQ8BQO9BWmFxt8DPC9oYhAuCCswFK5YQ"
type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[

function load() {
if (GBrowserIsCompatible()) {

function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}


var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.778855861649966, -79.98664855957031), 13);

}



Notice: Undefined variable: listingRecords in /home/content/g/r/e/greenways1/html/map.php on line 43

Warning: Invalid argument supplied for foreach() in /home/content/g/r/e/greenways1/html/map.php on line 43


}


//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 200px; height: 200px"></div>



</body>
</html>

Here's my code in dreamweaver:

<?php

require_once "/home/content/g/r/e/greenways1/html/cmsAdmin/lib/viewer_functions.php";

list($mapRecords, $mapMetaData) = getRecords(array(
'tableName' => 'map',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$mapRecord = @$mapRecords[0]; // get first record

?>
<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzWpdtAJy15_mFvJb9uOTTxSpUoc7Yr5GTKWfF5EG52h_OrBQ8BQO9BWmFxt8DPC9oYhAuCCswFK5YQ"
type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[

function load() {
if (GBrowserIsCompatible()) {

function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}


var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.778855861649966, -79.98664855957031), 13);

}


<?php foreach ($listingRecords as $record): ?>

var point = new GLatLng(<?php echo $mapRecord['latitude'] ?>,<?php echo $mapRecord['longitude'] ?>);
var marker = createMarker(point,'<?php echo htmlspecialchars($record['address'], ENT_QUOTES) ?>, <?php echo htmlspecialchars($record['city'], ENT_QUOTES) ?>')
map.addOverlay(marker);

<?php endforeach; ?>

}


//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 200px; height: 200px"></div>



</body>
</html>

Thanks for all your help
John C. Morris
Interdimensional Designs
www.covdesigns.com

By blind2uriz - February 27, 2009

When I made a map section in CMS builder and then input the lat and long and then inserted in dreamweaver, it worked, i got the map but didn't get any markers or anything, so now i'm trying to go back to the map.php code i was using and trying to figure out what is going on. could it be something in the php at the top of my page?
John C. Morris
Interdimensional Designs
www.covdesigns.com

By ross - February 27, 2009

Did you upload the latest version of map.php to your server? The link from your previous post is still going to a blank white screen.

Could you send me a link to the page you are working on now?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Help with Google Maps

By blind2uriz - March 1, 2009

Here is what I have right now. I've been trying all weekend to figure this out but can't. Hopefully someone can figure this out. Here's the source from uploaded map.php:

<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzWpdtAJy15_mFvJb9uOTTxSpUoc7Yr5GTKWfF5EG52h_OrBQ8BQO9BWmFxt8DPC9oYhAuCCswFK5YQ"
type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[

function load() {
if (GBrowserIsCompatible()) {

function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}


var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.778855861649966, -79.98664855957031), 13);

}




var point = new GLatLng(,);
var marker = createMarker(point,'107 N. Wills Ave., Covington')
map.addOverlay(marker);



}


//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>



</body>
</html>

Here's the code of map.php in dreamweaver:

<?php

require_once "/home/content/g/r/e/greenways1/html/cmsAdmin/lib/viewer_functions.php";

list($listingRecords, $listingMetaData) = getRecords(array(
'tableName' => 'listing',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$listingRecord = @$listingRecords[0]; // get first record

?>
<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzWpdtAJy15_mFvJb9uOTTxSpUoc7Yr5GTKWfF5EG52h_OrBQ8BQO9BWmFxt8DPC9oYhAuCCswFK5YQ"
type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[

function load() {
if (GBrowserIsCompatible()) {

function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}


var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.778855861649966, -79.98664855957031), 13);

}


<?php foreach ($listingRecords as $record): ?>

var point = new GLatLng(<?php echo $listingRecord['latitude'] ?>,<?php echo $listingRecord['longitude'] ?>);
var marker = createMarker(point,'<?php echo htmlspecialchars($record['address'], ENT_QUOTES) ?>, <?php echo htmlspecialchars($record['city'], ENT_QUOTES) ?>')
map.addOverlay(marker);

<?php endforeach; ?>

}


//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>



</body>
</html>

In the view source on the web, it's not pulling the GLatLng info that it needs. But I can't figure out how to get it to work.
John C. Morris
Interdimensional Designs
www.covdesigns.com

By ross - March 2, 2009

Hi there.

I think the problem is going to be that you are using two different variables in your code. The lat/long uses:

$listingRecord['latitude']

and for the rest of the values you are using:

$record['address']

I think you'll want to use $listingRecord but double check your code and let me know :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Help with Google Maps

By blind2uriz - March 2, 2009

I filled in all the $record's w/ $listingRecord and it still doesn't work. When I view source on www.idsitepreview.com/map.php, this line is working correctly:

var marker = createMarker(point,'<?php echo htmlspecialchars($listingRecord['address'], ENT_QUOTES) ?>, <?php echo htmlspecialchars($listingRecord['city'], ENT_QUOTES) ?>')

but I still can't get anything on the GLatLng line. Any more thoughts? Thanks.

John
John C. Morris
Interdimensional Designs
www.covdesigns.com