Hi there,
I'm new in using Google-Maps-API and I'm suprised, that the tutorial
for the store locator was soo easy :) - it works, the way it should.
The only problem is, that I need to change same functions but I'm not
sure how.
First of all I want that the adress is shown on the map though there
is no marker next to it. Right now I'm using the data of the tutorial
- later the markers will be all over Europe.
I think that this function has to be modified - but how?
If I enter Berlin for example, the map does not move and only says
that there is no result.
function searchLocations() {
var address = document.getElementById("addressInput").value;
geocoder.getLatLng(address, function(latlng) {
if (!latlng) {
alert(address + " not found");
} else {
searchLocationsNear(latlng);
}
});
}
function searchLocationsNear(center) {
var radius = document.getElementById("radiusSelect").value;
var searchUrl = "http://www.binichschwanger.net/facebook/
phpsqlsearch_genxml.php?lat=" + center.lat() + "&lng=" + center.lng()
+ "&radius=" + radius;
GDownloadUrl(searchUrl, function(data) {
var xml = GXml.parse(data);
var markers =
xml.documentElement.getElementsByTagName("marker");
map.clearOverlays();
var sidebar = document.getElementById("sidebar");
sidebar.innerHTML = "";
if (markers.length == 0) {
sidebar.innerHTML = "No results found.";
map.setCenter(new GLatLng(40, -100), 4);
return;
}
var bounds = new GLatLngBounds();
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var distance =
parseFloat(markers[i].getAttribute("distance"));
var point = new
GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, name, address);
map.addOverlay(marker);
var sidebarEntry = createSidebarEntry(marker, name, address,
distance);
sidebar.appendChild(sidebarEntry);
bounds.extend(point);
}
map.setCenter(bounds.getCenter(),
map.getBoundsZoomLevel(bounds));
});
}
Then the locator from the tutorial always show USA when I'm on the
landing page. Where can I change that? I want to set the center of the
map to Germany, but I could not find where I can do this.
I hope I could explain what I try to do and where my problems are. I
hope anybody can help me.
Thanks!
--
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.