On Jul 21, 9:04 am, Jenn <[email protected]> wrote:
> I have a text input box that you can type in an address, city, state,
> whatever. When you click off the box this function (changeLoc) is
> called to recenter the map on this new location. Very simple. But the
> "map.setCenter" doesn't work. The map reloads but stays at the old
> center (you can see it both on the map and in the popup - getCenter
> shows the old center still. Anyone see anything wrong? If it matters,
> there are markers on the map that after I recenter I delete and redraw
> - maybe I need to delete all markers before moving centers?
>
> ** Also, I notice people on these boards suggesting set_center. How is
> set_center any different than setCenter? I can't find any
> documentation on set_center but it doesn't throw an error.
The original name for the function was set_center in v3, it was
changes to setCenter.
>
> function changeLoc() {
> location_input = document.getElementById("location_input").value;
> if (location_input != "") {
> // Geocode new location
> geocoder.geocode( { 'address': location_input},
> function(results,
> status) {
> if (status == google.maps.GeocoderStatus.OK) {
> //alert("Setting center to: " +
> results[0].geometry.location);
> map.setCenter = results[0].geometry.location;
> alert("Wanted Center: " +
> results[0].geometry.location + " -
> Current Center: " + map.getCenter());
> //redrawMarkers();
> } else {
> alert("Invalid location entered.");
> }
> });
> }
>
> }
>
> Sorry for the code - my dev site is behind a firewall and don't really
> want to move it to a production machine until its more stable.
Can't test it then.
But I would expect this to not do what you expect:
map.setCenter = results[0].geometry.location;
-- Larry
>
> Thanks,
> Jenn
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.