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+
"<br/>MAC: "+result.mac.to_s+
"<br/><br/><a
href=''/stats/table''>Table View</a>"
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),da.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
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 <simon.wilkinson at gmail.com> 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+ > "<br/>MAC: "+result.mac.to_s+ > "<br/><br/><a href=''/stats/table''>Table View</a>" > > > 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
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 <simon.wilkinson at gmail.com> 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+ > "<br/>MAC: "+result.mac.to_s+ > "<br/><br/><a href=''/stats/table''>Table View</a>" > > > 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
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 <ajturner at highearthorbit.com>
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 <simon.wilkinson at gmail.com> 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+
> > "<br/>MAC: "+result.mac.to_s+
> > "<br/><br/><a
href=''/stats/table''>Table View</a>"
> >
> >
> > 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