On Oct 7, 10:11 am, Dave <dave.war...@gmail.com> wrote: > You guys are awesome. Now it's working. > > I have one final issue with this, though. The infowindow is being > cutoff, I think because we're setting the map center to be the marker, > and then the infowindow appears above it. > > Is there a way to have the infowindow fit inside the map area, just > like it does with the click event?
call map.setCenter before you trigger the click event if that doesn't work, call it using a delay (setTimeout). -- Larry > > If not, is there an easy formula to plug into the -- > map.setCenter(marker.getPosition()); -- that will make the map center > to be a little bit above the marker's position? > > Thanks guys. I really appreciate your help & quick responses. > > On Oct 7, 12:30 pm, Chad Killingsworth > > > > <chadkillingswo...@missouristate.edu> wrote: > > You appear to have missed Larry's trigger code - it should go right > > after line 367: > > > google.maps.event.trigger(marker, "click"); > > map.setCenter(marker.getPosition()); > > map.setZoom(15) ; > > > Chad Killingsworth > > > On Oct 7, 10:57 am, Dave <dave.war...@gmail.com> wrote: > > > > And I should have clarified... it does display the marker on the map > > > (just as it did before). And clicking the marker does open the > > > infowindow. > > > > But the infowindow DOES NOT open when the page is loaded. > > > > On Oct 7, 11:56 am, Dave <dave.war...@gmail.com> wrote: > > > > > 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 -- 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.