From orion at cora.nwra.com Mon Nov 5 10:48:00 2007 From: orion at cora.nwra.com (Orion Poplawski) Date: Mon, 05 Nov 2007 08:48:00 -0700 Subject: [Ym4r-user] marker event listeners Message-ID: <472F3B30.8080904@cora.nwra.com> I'd like to add an event listener for dragging markers, but it looks like YM4R GM (and Mapstraction) doesn't support this. I need an init like: marker = new GMarker(... GEvent.addListener(marker, "dragend", function() { }) but the current setup makes "anonymous" markers - never creates variable that can be used to access them. Has anyone thought about this? Perhaps we can add a "varname" attribute to the overlays to allow further use of them? The follow adds support to make draggable markers (though you can't really use them until the above is addressed). Index: lib/gm_plugin/overlay.rb =================================================================== --- lib/gm_plugin/overlay.rb (revision 97) +++ lib/gm_plugin/overlay.rb (working copy) @@ -25,11 +25,13 @@ end #Creates a marker: If an info_window or info_window_tabs is present, the response to the click action from the user is setup here. def create - if @options.empty? - creation = "new GMarker(#{MappingObject.javascriptify_variable(@point)})" - else - creation = "new GMarker(#{MappingObject.javascriptify_variable(@point)},#{MappingObject.javascriptify_variable(@options)})" + creation = "new GMarker(#{MappingObject.javascriptify_variable(@point)}" + if @options + creation += ",#{MappingObject.javascriptify_variable(@options)}" end + if @draggable + creation += ",#{MappingObject.javascriptify_variable(@options)}" + end if @info_window && @info_window.is_a?(String) creation = "addInfoWindowToMarker(#{creation},#{MappingObject.javascriptify_variable(@info_window)},#{MappingObject.javascriptify_variable(@info_window_options)})" elsif @info_window_tabs && @info_window_tabs.is_a?(Hash) -- Orion Poplawski Technical Manager 303-415-9701 x222 NWRA/CoRA Division FAX: 303-415-9702 3380 Mitchell Lane orion at cora.nwra.com Boulder, CO 80301 http://www.cora.nwra.com From orion at cora.nwra.com Tue Nov 6 00:56:13 2007 From: orion at cora.nwra.com (Orion Poplawski) Date: Mon, 05 Nov 2007 22:56:13 -0700 Subject: [Ym4r-user] marker event listeners In-Reply-To: <472F3B30.8080904@cora.nwra.com> References: <472F3B30.8080904@cora.nwra.com> Message-ID: <473001FD.9010602@cora.nwra.com> Orion Poplawski wrote: > I'd like to add an event listener for dragging markers, but it looks > like YM4R GM (and Mapstraction) doesn't support this. Well, I suppose if I read the docs closer... Got what I needed with: @marker = GMarker.new([lat, lng],:title => name, :draggable => true) @map.overlay_global_init(@marker, "marker") @map.event_init(@marker,"dragend",'function() { var latlng = marker.getPoint(); document.form.playground_lat.value = latlng.lat(); document.form.playground_lng.value = latlng.lng() }') This updates my form with the latitude and longitude of the dragged marker. Also attaching fixed version of my patch to add "draggable" option. There probably is a better, more generic way to add support for more options, but I'm a total ruby newbie and this point. -- Orion Poplawski Technical Manager 303-415-9701 x222 NWRA/CoRA Division FAX: 303-415-9702 3380 Mitchell Lane orion at cora.nwra.com Boulder, CO 80301 http://www.cora.nwra.com -------------- next part -------------- A non-text attachment was scrubbed... Name: ym4r_gm.patch Type: text/x-patch Size: 1278 bytes Desc: not available Url : http://rubyforge.org/pipermail/ym4r-user/attachments/20071105/83a8c297/attachment.bin From simon.wilkinson at gmail.com Mon Nov 12 09:57:23 2007 From: simon.wilkinson at gmail.com (Simon Wilkinson) Date: Mon, 12 Nov 2007 09:57:23 -0500 Subject: [Ym4r-user] info window tabs Message-ID: <529247150711120657r44bd19cbt973373dca443c479@mail.gmail.com> Hi, I am having some trouble getting the :info_window_tabs option working, and was wondering if anybody else has used this. I am trying this: marker = GMarker.new(latlng, :info_window_tabs => {title => infoString}) The API says that you should pass a hash, so this is what I am trying. Is there something that I'm missing here? It seems like it should be pretty straightforward. Thanks, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ym4r-user/attachments/20071112/51adf969/attachment.html