The only thing is, I am hiding multiple markers at a time. In this example I am hiding three. I dont want to run an if statement on all. How would I set these 3 into an array and then hide them at the same time?
On Apr 22, 3:12 pm, "[email protected]" <[email protected]> wrote: > On Apr 22, 12:01 pm, treyb <[email protected]> wrote: > > > I tried: > > > //gloabal variable > > var plotterhide=[]; > > > Weil = new google.maps.Marker({ > > map:map, > > animation: google.maps.Animation.DROP, > > position: new google.maps.LatLng(29.64834,-82.348688)}); > > perhaps: > Weil.myName = "Weil"; > plotterhide.push(Weil) > > then this will hide that marker: > for (var i=0; i<plottershide.length; i++) { > if (plottershide[i].myName == "Weil") > plottershide[i].setMap(null); > } > > Although depending on what you are trying to do, I might use an > associative array: > > plotterhide["Weil"] = Weil; // the google.maps.Marker Weil... > > then to hide it: > plotterhide["Weil"].setMap(null); > or to show it (assuming map is in the global scope): > plotterhide["Weil"].setMap(map); > > *** all code is untested... *** > > -- Larry > > > > > > > > > > > .....rest of markers > > plotterhide.push(marker,weil,CSE); > > > but nothing. When I put an alert to show what is in the array, I get > > [object object] in each spot. > > > On Apr 22, 2:00 pm, Rossko <[email protected]> wrote: > > > > > //gloabal variable > > > > var plotterhide=["marker","Weil","CSE","NRN"]; > > > > That seems to be just an array of strings. Strings don't have > > > setMap() methods and so on. > > > Wouldn't you need to make an array of marker objects? And maybe give > > > each marker some property so you can tell which of your categories it > > > belongs to? -- 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.
