attaching an id to a marker

1,232 views
Skip to first unread message

divinentd

unread,
Dec 23, 2010, 12:21:49 PM12/23/10
to Google Maps JavaScript API v3
Is there a way to attach an id attribute to a google.maps.MarkerImage
or google.maps.Marker? Our QA engineers are writing automated tests to
click on the Markers using rudimentary JavaScript, and this would
really help them.

The only way I can think to do it is grab all the <img> within the
map, and filter out those that are not from our domain, and the
shadows, isolating the marker images by process of elimination. But I
was hoping there was a more elegant solution that wouldn't require the
extra loop.

Thanks!
-Nils

Rossko

unread,
Dec 23, 2010, 4:14:02 PM12/23/10
to Google Maps JavaScript API v3
> Is there a way to attach an id attribute to a google.maps.MarkerImage
> or google.maps.Marker?

I doubt you'd want to mess with the image ; that might be used by
several markers.

Example discussion abut tagging markers
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/5ce48ea3c39c35da/b478ad0fb37fa094

I'd rrecommend avoiding a simple marker.id property due to the risk of
clashing with someone else's use of a same-named property ; maybe
marker.test_id instead?

Nils Devine

unread,
Dec 23, 2010, 4:18:58 PM12/23/10
to google-map...@googlegroups.com
Thanks! I'll give that a read.


--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.




--
Nils T. Devine

Chris Broadfoot

unread,
Dec 23, 2010, 6:39:59 PM12/23/10
to google-map...@googlegroups.com

Indeed!

Maps API Markers are JavaScript objects, which means you're free to set and get any exposed property from it.

As Rossko says, best to ensure the property you're using for tests doesn't conflict with ones in the Maps API or your own code. Suffixing or prefixing with an underscore ( _ ) will ensure there isn't a conflict with the API.

Chris.

On Dec 24, 2010 8:19 AM, "Nils Devine" <divi...@gmail.com> wrote:
> Thanks! I'll give that a read.
>
> On Thu, Dec 23, 2010 at 1:14 PM, Rossko <ros...@culzean.clara.co.uk> wrote:
>
>> > Is there a way to attach an id attribute to a google.maps.MarkerImage
>> > or google.maps.Marker?
>>
>> I doubt you'd want to mess with the image ; that might be used by
>> several markers.
>>
>> Example discussion abut tagging markers
>>
>> http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/5ce48ea3c39c35da/b478ad0fb37fa094
>>
>> I'd rrecommend avoiding a simple marker.id property due to the risk of
>> clashing with someone else's use of a same-named property ; maybe
>> marker.test_id instead?
>>
>> --
>> 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
>> google-map...@googlegroups.com.
>> To unsubscribe from this group, send email to
Reply all
Reply to author
Forward
0 new messages