Larry, you were right! I changed the code for content AND IT WORKS!!!! Now I am content too... :-) Thank you everybody for your assistance! Lennart
On 16 Apr, 23:37, "[email protected]" <[email protected]> wrote: > On Apr 16, 2:14 pm, "[email protected]" <[email protected]> > wrote: > > > On Apr 16, 12:29 pm, Lennart K <[email protected]> wrote: > > > > So far - so good. Now I've got the boxes displaying at the right > > > positions on the map. > > > But there's no text it just says [object] in the top left corner of > > > the box (and the closing-X to the right). > > > Does anybody know why? > > > Perhaps because you are passing in a "[object HTMLDivElement]" as the > > content. > > Does InfoBox support HTML Div Elements as content? I don't know I > > don't use it. > > But looking at the documentation and the examples they are the same > way, so that is probably not the problem. > > -- Larry > > > > > > > -- Larry > > > > Lennart > > > > On 16 Apr, 12:21, Lennart K <[email protected]> wrote: > > > > > Hi Gary and all, > > > > I have looked at your examples (many times) and I understand those two > > > > quite well. I have also looked the api reference. I also managed to > > > > create one window showing one text and before adding the eventlistener > > > > I also had all InfoBoxes spreading over th map at the same time. > > > > From this I conclude that my problem is the changes of positions and > > > > contents from one marker to another and the display > > > > of the InfoBoxes when a marker is clicked. I have spent some hours on > > > > this now making infoboxes code as paralel as possible to the code for > > > > InfoWindows and making a huge number of trials and errors. > > > > If these errors could be pointed out to me and how to replace then i > > > > wou´ld be most grateful. > > > > Thanks > > > > Lennart > > > > > The maps can be found > > > > athttp://www.skof.se/fbo/arkiv/Aterfynd/min_phpsqlajax_map3.php > > > > In order to make it display properly you may start > > > > athttp://www.skof.se/fbo/arkiv/Aterfynd/fynduttag.phpandselectabird > > > > species from the top left dropdown-menu. 'Tornfalk' is a good > > > > species > > > > to select . > > > > > On 16 Apr, 01:54, Gary Little <[email protected]> wrote: > > > > > > Lennart, > > > > > > You create InfoBoxes the same way as InfoWindows, e.g., > > > > > > infoBox = new InfoBox(boxOptions); > > > > > > The boxOptions are a superset of the InfoWindow options. > > > > > > Take a look at the examples > > > > > athttp://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox... > > > > > > Gary > > > > > > On Apr 15, 4:03 pm, Lennart K <[email protected]> wrote: > > > > > > > Now I have placed the InfoBox code the same way as I did for default > > > > > > InfoWindows. Something is still lacking though, since the InfoBoxes > > > > > > don't show up. InfoWindows have an initial variable: var > > > > > > infoWindow=new google.maps.InfoWindow. > > > > > > I can't quite figure out what it should be for InfoBox???? > > > > > > And since nothing shows up I don't know what's happening but it > > > > > > feels > > > > > > like I'm getting closer to the solution...(?) > > > > > > Good Night > > > > > > Lennart > > > > > > > On 15 Apr, 18:08, Lennart K <[email protected]> wrote: > > > > > > > > Hi again, > > > > > > > I was just going to post my next mail when Dave's arrived. Thanks > > > > > > > a > > > > > > > lot for the snippets, Dave. I'll have a look at them soon. I > > > > > > > really > > > > > > > have had some trouble with my infoBoxes since I'm not as familiar > > > > > > > as I > > > > > > > should with Javascript and object oriented coding. Perhaps I > > > > > > > shouldn't > > > > > > > be doing these things, but I can't give it up when I'm almost > > > > > > > ready > > > > > > > with the project. > > > > > > > However, Dave's snippets seems to be about google maps api3 > > > > > > > default > > > > > > > InfoWindows, which I managed to bind to the markers and to show > > > > > > > correctly. > > > > > > > Now I'm working with a set of custom info windows (infoBox.js, > > > > > > > which > > > > > > > was written by Gary who replied to my first mail) and I can't get > > > > > > > it > > > > > > > right. So I kindly ask for some more advice... > > > > > > > I think I make lot of structure and syntax errors. > > > > > > > Here are som questions about that with reference to the link > > > > > > > posted > > > > > > > with the first mail and Gary's reply. > > > > > > > Where should I place the eventlistener? Now it's in the for-loop, > > > > > > > that > > > > > > > puts the markers on the map. Cf. the previous eventlistener for > > > > > > > InfoWindow which is outside the loop. Since infoBox should behave > > > > > > > like > > > > > > > infoWindows it should be outside the loop too, shouldn't it? But > > > > > > > it > > > > > > > does not work to change all "InfoWindow" to "infoBox" in the > > > > > > > InfoWindow code, does it? > > > > > > > There are two parameters that are varying in the infoBox module: > > > > > > > the > > > > > > > position and the contents of the infoBox. > > > > > > > How do I get these? I have read the API reference but it doesn't > > > > > > > tell > > > > > > > me WHERE or HOW I put it into the context and make it work. > > > > > > > I have put in: 'position: this.getPosition()' into boxOptions > > > > > > > which > > > > > > > seems to be OK (no error message) but nothing happens. I should > > > > > > > use > > > > > > > set position() and set contents() but, again: how? and where? > > > > > > > Can I bind the infoBox to the markers like I have bound default > > > > > > > InfoWindows before? > > > > > > > Although this may be below the "google-maps-for-dummies" level I > > > > > > > still > > > > > > > think that there are someones who can help me. I have really > > > > > > > tried, > > > > > > > that's for sure. > > > > > > > Best regards and many thanks > > > > > > > Lennart > > > > > > > > On 15 Apr, 14:09, teknocreator <[email protected]> wrote: > > > > > > > > > Lennart, > > > > > > > > > Perhaps to help a bit with code (because it took me a bit too > > > > > > > > to find > > > > > > > > a solution as Gary suggested), here're a few snippets: > > > > > > > > > Declare a global variable for the infowindow in your javascript > > > > > > > > before > > > > > > > > any functions. So like > > > > > > > > > <script type="text/javascript"> > > > > > > > > > var mymap; > > > > > > > > var iw; // global for reusable infowindow > > > > > > > > ..... > > > > > > > > > then here's a snippet in something I was working on that > > > > > > > > initialized > > > > > > > > the map, a set of markers, and a listener for each marker. That > > > > > > > > listener would reset the infowindow content with info about the > > > > > > > > marker > > > > > > > > when it was clicked. > > > > > > > > > function initialize() { > > > > > > > > var myLatlng = new google.maps.LatLng(35, -105); > > > > > > > > var myOptions = { > > > > > > > > zoom: 4, > > > > > > > > center: myLatlng, > > > > > > > > mapTypeId: google.maps.MapTypeId.ROADMAP > > > > > > > > } > > > > > > > > mymap = new > > > > > > > > google.maps.Map(document.getElementById("map_canvas"), > > > > > > > > myOptions); > > > > > > > > > // initialize the global info window variable, the > > > > > > > > pixelOffset is > > > > > > > > optional > > > > > > > > > iw = new google.maps.InfoWindow({ > > > > > > > > content: "Stuff to initialize the window", > > > > > > > > pixelOffset: new google.maps.Size(5,0) > > > > > > > > }); > > > > > > > > > for (var i = 0; i < stnpt.length; i++) { > > > > > > > > var lat = stnpt[i][3]; > > > > > > > > var lon = stnpt[i][4]; > > > > > > > > var ovcenter = new google.maps.LatLng(lat,lon); > > > > > > > > var overlay = new CustomMarker(ovcenter, mymap); > > > > > > > > > // Register a click listener on each marker created. > > > > > > > > google.maps.event.addListener(overlay, 'click', > > > > > > > > (function(markerArg, index, stnid, name) { > > > > > > > > return function() { > > > > > > > > iw.setContent( > > > > > > > > 'Station: ' + stnid + '<br/> Name: ' + name); > > > > > > > > iw.open(mymap, markerArg); > > > > > > > > }; > > > > > > > > })(overlay, i, stnpt[i][0], stnpt[i][1])); // fed via > > > > > > > > into the > > > > > > > > function(markerArg,... above > > > > > > > > } > > > > > > > > > The stnpt array holds the station id, name, state, lat, and lon > > > > > > > > which > > > > > > > > is read in via a jQuery JSON file read function: > > > > > > > > > function read_stations() { > > > > > > > > var lmpjson = 'data/stnlist.json';*/ > > > > > > > > > $.getJSON(lmpjson, function(data) { > > > > > > > > $.each(data.marker, function(i, marker) { > > > > > > > > stnpt.push([marker.station_id, marker.station_name, > > > > > > > > marker.state, > > > > > > > > marker.lat, marker.lon]); > > > > > > > > }); > > > > > > > > }); > > > > > > > > > } > > > > > > > > > So you reuse the global infowindow variable via each marker's > > > > > > > > click > > > > > > > > listener and just set the windows content with the marker's > > > > > > > > info that > > > > > > > > you want to see when the mouse is clicked on a marker. In this > > > > > > > > case, > > > > > > > > I'm feeding the station ID and name. > > > > > > > > > Now, though I haven't done it this way exactly, you can also do > > > > > > > > something similar by binding an InfoWindow to your marker and > > > > > > > > there's > > > > > > > > a discussion of this here: > > > > > > > > >http://code.google.com/apis/maps/articles/phpsqlajax_v3.html > > > > > > > > > Hope that helps a bit more. I was where you're at now a few > > > > > > > > months > > > > > > > > back and searching for answers. > > > > > > > > > Dave > > > > > > > > > On Apr 14, 4:26 pm, Lennart K <[email protected]> wrote: > > > > > > > > > > Thanks Gary, for a very quick answer. I'll try to follow your > > > > > > > > > advice, > > > > > > > > > though javascript is not my "native language" if you see what > > > > > > > > > I > > > > > > > > > mean... > > > > > > > > > Lennart > > > > > > > > > > On 14 Apr, 20:13, Gary Little <[email protected]> wrote: > > > > > > > > > > > InfoBox has a setContent method for changing the content > > > > > > > > > > and a > > > > > > > > > > setPosition method for changing the position. > > > > > > > > > > > So in your click handler for a marker you can get the > > > > > > > > > > position of the > > > > > > > > > > marker > > ... > > läs mer »- Dölj citerad text - > > - Visa citerad 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 [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.
