PDA

View Full Version : Google Maps API :: Help Needed


cancer10
10-14-2009, 05:55 PM
Hi

I was wondering if there is any way I can display a google map by just passing the street address, city and country name in the API instead of Longitude and Latitude and the locations would appear as balloons as shown in the attached screenshot.


Pls help me.


Many Thanks

mlseim
10-14-2009, 06:15 PM
There are so many combinations of maps features ...

Do you mean this?
http://www.developer.com/tech/article.php/3615681/Introducing-Googles-Geocoding-Service

How are you "passing the street address"?
by a form?
by an XML file?
by a mouse-click on a map?

cancer10
10-14-2009, 06:25 PM
I want to hard code the street address in the code.

mlseim
10-14-2009, 07:12 PM
Show me what you already have for code.

cancer10
10-15-2009, 04:09 AM
Show me what you already have for code.

There you go...

I am trying to use one of google's examples.
also, when I click on those bullons, i dont get a bulloon popup, any idea why?


http://code.google.com/apis/maps/documentation/examples/marker-simple.html

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

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

// Add 10 markers to the map at random locations
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 10; i++) {
var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(latlng));
}
}
}

</script>
</head>

<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>

mlseim
10-15-2009, 05:52 AM
This topic is interesting, because Google doesn't really have
a way to easily mark a map based on an address ... BUT ...
it does utilize some sort of function exactly like that when you
use the "direction finder". It's almost like they can do it, but they
don't want to make it easy to use.

Example of the direction finder (view HTML source to see all of the coding) ...
http://www.catpin.com/google_directions/

What I've read about this are things like:
1) There are some other free databases for looking up home/business addresses, converting to GPS coordinates.
2) Not all addresses can be located, so there are some failures.
3) Even if an address comes back with coordinates, some are not properly marked (off by yards, blocks, or miles).

So Google came up with this explanation of how it works:
http://code.google.com/apis/maps/documentation/geocoding/index.html

I wish I had a better example, but maybe someone else has it figured out?