hi Ross, its greate, i really appreciate you help,

http://www.spotonsearch.co.uk/auto/xx/index.html

you can see its working very nice.....just i cant remove marker from
array.

batch[id].splice(batch[id],1);

is not working....but my target is
http://www.thinkproperty.com/property/search/map/alias/55905/1/20000/3000000/0/0

if u see this i need to make batter thn them.....if u really tell me
step by step how to achive that it would be very helpfull

what kind of database structure i need...now i got intreset in google
map. waiting your reply...thankyou very much ross

On Jun 16, 9:54 pm, Rossko <[email protected]> wrote:
> > hi ross, i dont understand how to define relation between batch[] and
> > marker[] you can see code by 
> > viewsourcehttp://www.spotonsearch.co.uk/auto/xx/index.html
>
> Well, we can ignore that now because your code no longer includes
> reference to marker[]
>
> I think you need to review your logic here
> You have a global array batch[], which contains only the 'id' of all
> loaded markers.
> When you load new markers, you check to see if each new marker's id is
> already known in batch[], and if it isn't, you add the marker to your
> map and save its 'id' in batch[].    If the marker's id is actually
> already in batch[], you do nothing - it's already added to the map.
>
> So far, so good.
>
> You've got some code in the add-new-marker section that tries to
> remove some overlay, though its not clear what.  I can't see any
> reason to try to remove an overlay just because you've added a new
> marker.
>
> The missing part seems to be looking at the batch[] array after adding
> a set of new markers, and removing any markers that weren't present in
> this update.    Even if that were done, you'd have trouble removing
> existing markers from the map because you have kept no reference to
> them; each was created only in local scope in the previous run of
> updateMarkers().
>
> There's more than one way to go about this, but this could be one
> approach:
>
> You need to remember the id's of markers that you've put on the map,
> and you also need to keep a reference to each of those markers in case
> you need to remove it some time later.
> You could combine those requirements by indexing your batch[] storage
> array by the marker 'id' (I assume they are unique!) and storing the
> whole marker
>
> In your updateMarkers(), instead of
>    batch.push(id);
>    var marker = createMarker(....
> do
>    var marker = createMarker(....
>    batch[id] = marker;
>
> You'd need to change the 'does it already exist' test from
>   for(ii=0; ii<batch.length; ii++)
>   {    if(batch[ii]=== id)
>   ...
> to something as simple as
>    if ( batch[id] ) { ...
> there's no need to loop, as you can address batch[] directly by 'id'
> and you just want to know if that entry exists or not.
>
> If it doesn't exist, you go on to make a new marker.
>
> If it does already exist, you need some means to distinguish between
> batch[] entries that have been found (because you want to keep them),
> and those that haven't (because you want to remove them later).
> One way to do that might be to set a flag on each batch[] item.  So,
> when a 'new' marker is found already in batch[id], do something like -
>    batch[id].keep_it = true;
> There's a trap here if you're not careful - you need to go back to the
> create-a-new-marker section and set the .keep_it flag there as well.
>
> After you've finished processing all the incoming markers data, and
> either creating new markers or keeping existing ones, you need to scan
> batch[] for the redundant ones.
> Run a loop through each batch[] entry by id - for (id in batch) - and
> test the .keep-it flag.
> If the flag is set, clear it down ready for the next updateMarkers()
> session - batch[id].keep_it = false;
> else
> remove the marker from the map - map.removeOverlay(batch[id]);
> and of course clear it from the array - delete batch[id];
>
> There would be cleverer ways to go about it, by not really destroying
> 'old' markers but just hiding them in case we might use them again
> later.  And you could make it more efficient by doing things like
> testing for the id before bothering to read the rest of the XML data.
> But get the basics working first.
>
> cheers, Ross K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to