I tried that and it didn't work. Just to make sure I put it in the correct place, here is the entire createSMarker function code:
(any other suggestions?) // Display sales markers & infowindows on the map function createSMarker(latlng, html) { var contentString = html; var marker = new google.maps.Marker({ position: latlng, map: map, icon: imageSales, zIndex: Math.round(latlng.lat()*-100000)<<5 }); // Open sales markers' infowindows on click event google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(contentString); infowindow.open(map,marker); }); return marker; } // end function createSMarker On Oct 7, 11:49 am, "geocode...@gmail.com" <geocode...@gmail.com> wrote: > On Oct 7, 8:45 am, Dave <dave.war...@gmail.com> wrote: > > > Do you have a quick code snippet as an example of how to return a > > marker right after it is created? > > At the end of the createSMarker function add the statement: > return marker; > > just before the final "}" > > -- Larry > > > > > > > On Oct 7, 10:49 am, "geocode...@gmail.com" <geocode...@gmail.com> > > wrote: > > > > On Oct 7, 7:36 am, "geocode...@gmail.com" <geocode...@gmail.com> > > > wrote: > > > > > On Oct 7, 7:20 am, Dave <dave.war...@gmail.com> wrote: > > > > > > I have a dropdown form where a user can choose a state. Depending on > > > > > which state is chosen, a single marker with an infowindow is returned > > > > > in a google map on a separate page. > > > > > > The infowindow will open when you click the marker... but I would like > > > > > it to open as soon as the new page loads. > > > > > > Here's the page with the dropdown > > > > > form:http://dev.aerometric.com/contact/ > > > > > It's in the left sidebar. > > > > > > Choose any state, hit search, and you'll be sent to a new page with > > > > > one result. > > > > > That doesn't seem to work for me. > > > > > > (the google map javascript is embedded at the bottom of the page) > > > > > > I'm sure it's something simple, I just don't understand javascript > > > > > that well. > > > > > What I would suggest is count the markers added to the map. If the > > > > number is one, trigger a click event on that marker. > > > > > Although as it looks like the page itself has the code embeded in it, > > > > you could just add this to your single marker pages: > > > > google.maps.event.trigger(marker, "click"); > > > > If you change your createSMarker function to actually return the > > > marker it creates... > > > > -- Larry > > > > > You might want to center on the one marker and zoom in closer also. > > > > map.setCenter(marker.getPosition()); > > > > map.setZoom(pick a number...) > > > > > -- Larry > > > > > > Any help is greatly appreciated. > > > > > > Thanks, > > > > > Dave- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - -- 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...@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.