ok, i did it today (again -.-") and it works this way
i am assuming you have a addMarker function AND you have a array where
you store your markers in
before creating the marker just so something like this:
function addMarker(){
if (markers.length<2){
addmarker code
}
}
if you are to lazy to figure it out check this
http://www.youspots.com/tests/fireteller2.php
(no clue how long it will stay there) and search for markers.length,
with a bit of copy and paste this can work ^^
On 6 Jun., 23:56, a jay <[email protected]> wrote:
> i am new to JS would you be able to provide a more detailed explanation ?
> i would like to limit the user to place 2 markers on the map.
> thanks
>
>
>
>
>
>
>
> On Mon, Jun 6, 2011 at 2:54 PM, en4ce <[email protected]> wrote:
> > this placeMarker(event.latLng); is a function not an array, to fill
> > your placeMarker array use the normal js methods
>
> > On 6 Jun., 23:35, a jay <[email protected]> wrote:
> > > hi, i am trying to limit the marker to add only two markers to a map on
> > > click event
> > > i wrote an event listener and added the following code to it:
>
> > > GEvent.addListener(map, 'click', function (overlay, latlng) {
> > > if (placeMarker.length < 2) {
> > > pendingLatLng = latlng;
> > > setTimeout("settleClick()", 225)
> > > }
> > > else {
> > > message("You can only select 2 points.");
> > > }
> > > });
>
> > > a sample click event which looks like the line below does work. what am i
> > > doing wrong ?:
> > > google.maps.event.addListener(map, 'click', function (event)
> > > {placeMarker(event.latLng); })
>
> > --
> > 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.
--
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.