From simon.wilkinson at gmail.com Tue Oct 16 11:51:48 2007 From: simon.wilkinson at gmail.com (Simon Wilkinson) Date: Tue, 16 Oct 2007 11:51:48 -0400 Subject: [Ym4r-user] can't define custom GIcon Message-ID: <529247150710160851y24b8f0d9jd0189636de8ca9de@mail.gmail.com> Hi, I am having trouble getting custom GIcons to display. Here is the code in my controller: @map = GMap.new("map_div") @map.control_init(:large_map => true,:map_type => true) @map.icon_global_init(GIcon.new(:image => "images/APBox-20.png "),"ap_none") infoString = "Friendly Name: "+result.friendly_name+ "
MAC: "+result.mac.to_s+ "

Table View" marker = GMarker.new(latlng, :info_window => infoString, :icon => "ap_none") point = GLatLng.new(latlng) @gmap_markers << marker @map.center_zoom_init(bounding_box_center(@gmap_markers), 15) @map.overlay_global_init(GMarkerGroup.new(true, @gmap_markers),"NOI") In my view I simply have: <%= @map.div(:width => 600,:height => 400) %> When I don't define the :icon property in the GMarker constructor, everything works properly. When I do, the map loads, but the marker isn't displayed, and none of the map controls appear either. The error I am getting in Firebug is: b has no properties. The error occurs on this line: z.prototype.rb=function(){var a=this,b=a.ta.iconAnchor,c=a.Zc=a.c.h(a.F),d= a.Th=new n(c.x-b.x,c.y-b.y-a.Z),e=new n(d.x+a.Z/2,d.y+a.Z/2 );return{divPixel:c,position:d,shadowPosition:e}}; which is line 805 in main.js. Has anybody else experienced this problem, or see what I am doing wrong? Any help would be appreciated. Thanks, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ym4r-user/attachments/20071016/534198f0/attachment.html From jay.doo at gmail.com Tue Oct 16 12:09:49 2007 From: jay.doo at gmail.com (Jay Douillard) Date: Tue, 16 Oct 2007 09:09:49 -0700 Subject: [Ym4r-user] can't define custom GIcon In-Reply-To: <529247150710160851y24b8f0d9jd0189636de8ca9de@mail.gmail.com> References: <529247150710160851y24b8f0d9jd0189636de8ca9de@mail.gmail.com> Message-ID: Looks like you haven't provided all of the information for your icon in your @map.icon_global_init @map.icon_global_init(GIcon.new(:image => "/images/icon_construction.png", :icon_size => GSize.new(15,15),:icon_anchor => GPoint.new(7,7),:info_window_anchor => GPoint.new(9,2)),"icon_construction") is the example @ http://thepochisuperstarmegashow.com/2006/06/03/google-maps-yahoo-traffic-mash-up/ I ended up having issues and just defined the icons using javascript in the typical google maps fashion. -Jay On 10/16/07, Simon Wilkinson wrote: > > Hi, > > I am having trouble getting custom GIcons to display. Here is the code in > my controller: > > @map = GMap.new("map_div") > @map.control_init(:large_map => true,:map_type => true) > > @map.icon_global_init(GIcon.new(:image => "images/APBox-20.png > "),"ap_none") > infoString = "Friendly Name: "+result.friendly_name+ > "
MAC: "+result.mac.to_s+ > "

Table View" > > > marker = GMarker.new(latlng, :info_window => infoString, :icon => > "ap_none") > point = GLatLng.new(latlng) > @gmap_markers << marker > > @map.center_zoom_init(bounding_box_center(@gmap_markers), 15) > @map.overlay_global_init(GMarkerGroup.new(true, @gmap_markers),"NOI") > > In my view I simply have: > > <%= @map.div(:width => 600,:height => 400) %> > > When I don't define the :icon property in the GMarker constructor, > everything works properly. When I do, the map loads, but the marker isn't > displayed, and none of the map controls appear either. The error I am > getting in Firebug is: > > b has no properties. > > The error occurs on this line: > > z.prototype.rb=function(){var a=this,b=a.ta.iconAnchor,c=a.Zc=a.c.h(a.F > ),d=a.Th=new n(c.x-b.x,c.y-b.y-a.Z),e=new n(d.x+a.Z/2,d.y+a.Z/2 > );return{divPixel:c,position:d,shadowPosition:e}}; > > which is line 805 in main.js. > > Has anybody else experienced this problem, or see what I am doing wrong? > Any help would be appreciated. > > Thanks, > > Simon > > _______________________________________________ > Ym4r-user mailing list > Ym4r-user at rubyforge.org > http://rubyforge.org/mailman/listinfo/ym4r-user > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ym4r-user/attachments/20071016/d1c5e88e/attachment.html From ajturner at highearthorbit.com Tue Oct 16 12:46:11 2007 From: ajturner at highearthorbit.com (Andrew Turner) Date: Tue, 16 Oct 2007 12:46:11 -0400 Subject: [Ym4r-user] can't define custom GIcon In-Reply-To: <529247150710160851y24b8f0d9jd0189636de8ca9de@mail.gmail.com> References: <529247150710160851y24b8f0d9jd0189636de8ca9de@mail.gmail.com> Message-ID: <4a31cd840710160946u15bc726cm2aeefd0e14fe9977@mail.gmail.com> This error usually occurs when you try to use a GMap before you have centered it. Annoying 'bug' or need to initialize in GMap. by the way, have you tried the YM4R_Mapstraction? :) On 10/16/07, Simon Wilkinson wrote: > Hi, > > I am having trouble getting custom GIcons to display. Here is the code in > my controller: > > @map = GMap.new("map_div") > @map.control_init(:large_map => true,:map_type => true) > > @map.icon_global_init(GIcon.new(:image => > "images/APBox-20.png"),"ap_none") > infoString = "Friendly Name: "+result.friendly_name+ > "
MAC: "+result.mac.to_s+ > "

Table View" > > > marker = GMarker.new(latlng, :info_window => infoString, :icon => > "ap_none") > point = GLatLng.new(latlng) > @gmap_markers << marker > > > @map.center_zoom_init(bounding_box_center(@gmap_markers), > 15) > @map.overlay_global_init(GMarkerGroup.new(true, @gmap_markers),"NOI") > > In my view I simply have: > > <%= @map.div(:width => 600,:height => 400) %> > > When I don't define the :icon property in the GMarker constructor, > everything works properly. When I do, the map loads, but the marker isn't > displayed, and none of the map controls appear either. The error I am > getting in Firebug is: > > b has no properties. > > The error occurs on this line: > > z.prototype.rb=function(){var > a=this,b=a.ta.iconAnchor,c=a.Zc=a.c.h(a.F),d=a.Th=new > n(c.x-b.x,c.y-b.y-a.Z),e=new > n(d.x+a.Z/2,d.y+a.Z/2);return{divPixel:c,position:d,shadowPosition:e}}; > > which is line 805 in main.js. > > Has anybody else experienced this problem, or see what I am doing wrong? > Any help would be appreciated. > > Thanks, > > Simon > > _______________________________________________ > Ym4r-user mailing list > Ym4r-user at rubyforge.org > http://rubyforge.org/mailman/listinfo/ym4r-user > -- Andrew Turner ajturner at highearthorbit.com 42.2774N x 83.7611W http://highearthorbit.com Ann Arbor, Michigan, USA Introduction to Neogeography - http://oreilly.com/catalog/neogeography From simon.wilkinson at gmail.com Wed Oct 17 09:48:29 2007 From: simon.wilkinson at gmail.com (Simon Wilkinson) Date: Wed, 17 Oct 2007 09:48:29 -0400 Subject: [Ym4r-user] can't define custom GIcon In-Reply-To: <4a31cd840710160946u15bc726cm2aeefd0e14fe9977@mail.gmail.com> References: <529247150710160851y24b8f0d9jd0189636de8ca9de@mail.gmail.com> <4a31cd840710160946u15bc726cm2aeefd0e14fe9977@mail.gmail.com> Message-ID: <529247150710170648w784a3bb2x2796b47bf2a91a7d@mail.gmail.com> Thanks, I added in the missing attributes (didn't realize all were required) and that seems to have solved the problem. Custom icons are now being displayed nicely. I do have another question now: I am trying to set the zoom level of the map dynamically based on the markers that I am adding to it, so that all of the markers will be visible. Here is what I am trying: @gmap_points = Array.new latlng = Array.new latlng[0] = latitude latlng[1] = longitude @gmap_points << latlng @bounds = GBounds.new(@gmap_points) bounds = Variable.new(@bounds) @map.record_init('map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); ') So I am trying to create a GBounds object with my array of points, and then bind it to a javascript variable so that I can pass in the appropriate javascript code into the onLoad function. This seems to be working ok, as this is the javascript that gets output: window.onload = addCodeToFunction(window.onload,function() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_div")); map.addOverlay(NOI); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); } But I am getting this error: this.v has no properties on line 611 of main.js. Looking at the code above the onload function, I can't see the bounds variable being declared anywhere, so I think this might be the issue, but I'm not sure why it isn't working. Can anybody see where I may have made a mistake, or has anybody else implemented this functionality using ym4r successfully? Thanks again, Simon On 16/10/2007, Andrew Turner wrote: > > This error usually occurs when you try to use a GMap before you have > centered it. Annoying 'bug' or need to initialize in GMap. > > by the way, have you tried the YM4R_Mapstraction? :) > > On 10/16/07, Simon Wilkinson wrote: > > Hi, > > > > I am having trouble getting custom GIcons to display. Here is the code > in > > my controller: > > > > @map = GMap.new("map_div") > > @map.control_init(:large_map => true,:map_type => true) > > > > @map.icon_global_init(GIcon.new(:image => > > "images/APBox-20.png"),"ap_none") > > infoString = "Friendly Name: "+result.friendly_name+ > > "
MAC: "+result.mac.to_s+ > > "

Table View" > > > > > > marker = GMarker.new(latlng, :info_window => infoString, :icon > => > > "ap_none") > > point = GLatLng.new(latlng) > > @gmap_markers << marker > > > > > > @map.center_zoom_init(bounding_box_center(@gmap_markers), > > 15) > > @map.overlay_global_init(GMarkerGroup.new(true, > @gmap_markers),"NOI") > > > > In my view I simply have: > > > > <%= @map.div(:width => 600,:height => 400) %> > > > > When I don't define the :icon property in the GMarker constructor, > > everything works properly. When I do, the map loads, but the marker > isn't > > displayed, and none of the map controls appear either. The error I am > > getting in Firebug is: > > > > b has no properties. > > > > The error occurs on this line: > > > > z.prototype.rb=function(){var > > a=this,b=a.ta.iconAnchor,c=a.Zc=a.c.h(a.F),d=a.Th=new > > n(c.x-b.x,c.y-b.y-a.Z),e=new > > n(d.x+a.Z/2,d.y+a.Z/2);return{divPixel:c,position:d,shadowPosition:e}}; > > > > which is line 805 in main.js. > > > > Has anybody else experienced this problem, or see what I am doing wrong? > > Any help would be appreciated. > > > > Thanks, > > > > Simon > > > > _______________________________________________ > > Ym4r-user mailing list > > Ym4r-user at rubyforge.org > > http://rubyforge.org/mailman/listinfo/ym4r-user > > > > > -- > Andrew Turner > ajturner at highearthorbit.com 42.2774N x 83.7611W > http://highearthorbit.com Ann Arbor, Michigan, USA > Introduction to Neogeography - http://oreilly.com/catalog/neogeography > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ym4r-user/attachments/20071017/ec1dfb4e/attachment-0001.html From simon.wilkinson at gmail.com Wed Oct 17 11:07:00 2007 From: simon.wilkinson at gmail.com (Simon Wilkinson) Date: Wed, 17 Oct 2007 11:07:00 -0400 Subject: [Ym4r-user] GMarkerGroup center_and_zoom_on_markers problem Message-ID: <529247150710170807x1c6a6339nfd0c6758212179b2@mail.gmail.com> Hi, I found the funcitoned mentioned in title (center_and_zoom_on_markers) but am having troubles getting it working. I have several markers being added to an array (@gmap_markers = []) in the following manner: marker = GMarker.new(latlng, :info_window => infoString, :icon => my_icon) @gmap_markers << marker I am then trying to do the following: group = GMarkerGroup.new(true, @gmap_markers) @map.overlay_global_init(group,"NOI") @map.record_init group.center_and_zoom_on_markers But I get the following error: this.v has no properties (on line 611 of main.js, according to Firebug). If I replace the line "@map.record_init group.center_and_zoom_on_markers" with "@map.center_zoom_init(bounding_box_center(@gmap_markers), 9)" everything works as expected. bounding_box_center is just a function I wrote quickly to get the center point of the group of markers. Has anybody else used the center_and_zoom_on_markers method successfully? I'm not sure what the problem is, as I think I am using it correctly. Any help would be appreciated. Thanks, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ym4r-user/attachments/20071017/fc7fd87e/attachment.html