Ok thank you, I will try that. Sounds good.

On 29.06.11 15:24, "Pil" <[email protected]> wrote:

>This should work (untested pseudocode):
>
>function createMarker(id) {
>
>  var marker = new google.maps.Marker({
>    position: latlng,
>    icon: image,
>    map: map,
>    title: name,
>    draggable: true,
>    id: id
>   });
>  gmarkers.push(marker);
>}
>
>Now it should be possible to access every marker in gmarkers array by
>its id:
>
> for (var i = 0; i < gmarkers.length; i++) {
>  if (gmarkers[i].id == someid) {
>    // do soemthing with your specific marker
>  }
> }
>
>
>
>On Jun 29, 12:21 pm, MrUpsidown <[email protected]> wrote:
>> Hi
>>
>> Within a function, I create several markers and I need to assign them
>> a specific ID.
>>
>>                 var marker = new google.maps.Marker({
>>                     position: latlng,
>>                     icon: image,
>>                     map: map,
>>                     title: name,
>>                     draggable: true
>>                 });
>>
>>                 marker.myid = markerid;
>>
>>                 gmarkers.push(marker);
>>
>> Now I have another function from which I want to 'click' a link that
>> contains the marker id and fire a click event
>>
>>             function spotClick(markerId) {
>>
>>                 google.maps.event.trigger(gmarkers[markerId],"click");
>>
>>             }
>>
>> This obviously does not work. How am I supposed to refer to marker by
>> the ID I assigned to it earlier?
>>
>> Thanks in advance!
>
>-- 
>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.

Reply via email to