I can't take a look at your code right now as I have an extremely slow connection right now, but simply do as Larry suggested. You might create two global fields, e.g. (some simplified/modified code of mine):
var blueMarkers = new Array(); var redMarker; Then, when creating the new markers, make sure to store them in the appropriate fields: // Creation of blue markers for(var i = 0; i < events.length; i++) { var tempMarker = new google.maps.Marker({ position: new google.maps.LatLng(events[i].Latitude, events[i].Longitude), title: events[i].Name, map: jMap }); //Here you can do some other stuff with the created marker if you want to // Push the marker into your array blueMarkers.push(tempMarker); } // Creating the red marker redMarker = new google.maps.Marker({ ... }); Then repositioning the red on is fairly simple: redMarker.setPosition(<new position as LatLng object>); And for finding the closest neigbour, simply iterate through your blueMarkers array, calculate the distance of each marker to your redMarker and pick the one with the smallest distance (here's how you do it: http://code.google.com/intl/en/apis/maps/documentation/javascript/geometry.html#Distance). Then, if you have e.g. blueMarkers[42] as the closest match, do the following (assuming map is your google.maps.Map object): var bounds = new google.maps.LatLngBounds(); bounds.extend(redMarker.getPosition()); bounds.extend(blueMarkers[42].getPosition()); map.fitBounds(bounds); This should work. -- 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 google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.