Custom YM4R Google Map Marker


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. map = GMap.new( Constants::GM_DIV_ID, Constants::GM_NAME )
  2.  
  3. # Define the start and end icons
  4. map.icon_global_init( GIcon.new( :image => "/images/google_maps/icong.png", :icon_size => GSize.new( 24,38 ), :icon_anchor => GPoint.new(12,38), :info_window_anchor => GPoint.new(9,2) ), "icon_start")
  5. map.icon_global_init( GIcon.new( :image => "/images/google_maps/iconr.png", :icon_size => GSize.new( 24,38 ), :icon_anchor => GPoint.new(12,38), :info_window_anchor => GPoint.new(9,2) ), "icon_stop" )
  6.  
  7. icon_start = Variable.new("icon_start"); icon_stop = Variable.new("icon_stop")
  8.  
  9. if respond_to?( "start_lat" ) && respond_to?( "start_long" )
  10. map.center_zoom_init( [start_lat, start_long], Constants::GM_ZOOM )
  11. map.overlay_init( GMarker.new( [start_lat, start_long], { :icon => icon_start, :title => name + " start", :info_window => "start" } ) )
  12. end
  13.  
  14. if respond_to?( "end_lat" ) && respond_to?( "end_long" )
  15. map.overlay_init( GMarker.new( [end_lat, end_long], { :icon => icon_stop, :title => name + " end", :info_window => "end" } ) )
  16. end

URL: http://www.postal-code.com/binarycode/2007/11/28/google-map-markers-in-ym4rgm/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.