I am pulling addresses from a mysql database and using the geocodeAll
() function to pin my markers to the map. I need to use custom markers
as well as having each marker feature an onclick function to display
the address.
I have this setup running fine in another test page I created, but
can't get those two features incorporated into this code for some
reason. Would anyone be able to take a look and help out or point me
in the right direction? I think I've read through every tutorial and
example out there but I'm definitely missing something.
Here is my basic code structure with my attempts at custom markers and
icon bubbles stripped out:
<script type="text/javascript">
//<![CDATA[
var map;
var geocoder = null;
var addressMarker;
var addresses = [
<?php
$query = "SELECT * FROM ...";
$result = mysql_query($query);
while( $row = mysql_fetch_assoc( $result ) ) {
$id = $row["id"];
$address = $row["address"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];
echo "\"$address, $city, $state, $zip\", \n";
}
?>
];
var numGeocoded = 0;
function geocodeAll() {
if (numGeocoded < addresses.length) {
geocoder.getLocations(addresses[numGeocoded],
addressResolved);
}
}
function addressResolved(response) {
var delay = 0;
if (response.Status.code == 620) {
// Too fast, try again, with a small pause
delay = 500;
} else {
if (response.Status.code == 200) {
// Success; do something with the address.
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
}
// Move onto the next address; this skips bad addresses, too.
numGeocoded += 1;
}
window.setTimeout(geocodeAll, delay);
}
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map-large"));
map.setMapType(G_HYBRID_MAP);
map.setUIToDefault();
map.setCenter(new GLatLng(34.633268, -97.676926), 4);
geocoder = new GClientGeocoder();
geocoder.setCache(null);
window.setTimeout(geocodeAll, 50);
}
}
//]]>
</script>
Any help would be greatly appreciated!
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.