Wednesday, August 11, 2010

Re: Remove marker problem

Great thanks, a lot!

On Aug 10, 6:29 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Aug 10, 9:18 am, Thomas <thomasp.gr...@gmail.com> wrote:
>
>
>
>
>
> > Hello,
>
> > I do have lots of trouble with removing a marker. I use the code below
> > to set a marker on a specific country in Google Maps. The program
> > itself includes a big list of countries the user can choose one after
> > the other. The program then jumps to the country on Google maps and
> > sets the marker. As you probably all know it sets multiple markers. I
> > now try to find a way to change the below code in the way that after a
> > new marker will be set the one / all the ones before will be deleted.
> > So that there always is only one marker visible on the map. The
> > program will be a Google Chrome extension and therefore is not only
> > anymore.
>
> > Thanks a lot for your help in advance.
>
> > Cheers,
> > Thomas
>
> > function codeAddress()
> > {
> >         //get the country
> >         var address = country;
>
> >         if (geocoder) {
> >           geocoder.geocode( { 'address': address}, function(results, status)
> > {
> >                 if (status == google.maps.GeocoderStatus.OK) {
> >                   map.setCenter(results[0].geometry.location);
> >                   var marker = new google.maps.Marker({
> >                           map: map,
> >                           position: results[0].geometry.location
> >                   });
> >                 } else {
> >                   alert("Geocode was not successful for the following reason: " +
> > status);
> >                 }
> >           });
>
> This looks like v3 code.  The v3 group is:http://groups.google.com/group/google-maps-js-api-v3/topics
>
> To remove a marker in v3 do:
> marker.setMap(null);
>
> but that will be difficult for you without rearranging your code as
> your marker variable is local to the geocoder callback function.
>
> Please post a link to your map, not code if you have a problem and are
> looking for help, per the posting guideline in both this group and the
> v3 group.
>
>   -- Larry
>
>
>
>
>
> > }
> > }- Hide quoted text -
>
> > - Show quoted text -

--
You received this message because you are subscribed to the Google Groups "Google Maps API" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate