1

アプリケーションで gmaps4rails を使用して gmaps を表示しています。マップ ポイントを正しく取得していますが、マップ内の現在の場所と別の場所を区別できません。次の方法で 2 つの場所に異なるマーカーを使用することを考えていますが、私のために働いていませんでした

私のコントローラー

def profile

   @googlemaplocation=Location.find_by_id("#{params[:clinic_id]}")

    @json1 = @googlemaplocation.to_gmaps4rails do |locations, marker|

  marker.picture({
                  :picture => "http://www.google.com/mapfiles/dd-start.png",
                  :width   => 32,
                  :height  => 32
                 })
  end

    @neargooglemaplocation=@googlemaplocation.nearbys(10)
    @json2= @neargooglemaplocation.to_gmaps4rails do |locations, marker|

  marker.picture({
                  :picture => "http://www.google.com/mapfiles/dd-start.png",
                  :width   => 32,
                  :height  => 32
                 })
  end

    @json = (JSON.parse(@json1) + JSON.parse(@json2)).to_json

  end

私の見解

<%= gmaps(:markers => { :data => @json } ) %>

同じマップに 2 つの異なるマーカーを表示したい場合はどうすればよいですか

ありがとう & よろしく ハリ・クリシュナ

4

1 に答える 1

1

apneadivingで述べたように、さまざまな画像を使用できます。例えば ​​:

def profile

   @googlemaplocation=Location.find_by_id("#{params[:clinic_id]}")

    @json1 = @googlemaplocation.to_gmaps4rails do |locations, marker|

  marker.picture({
                  :picture => "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png",
                  :width   => 32,
                  :height  => 32
                 })
  end

    @neargooglemaplocation=@googlemaplocation.nearbys(10)
    @json2= @neargooglemaplocation.to_gmaps4rails do |locations, marker|

  marker.picture({
                  :picture => "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png",
                  :width   => 32,
                  :height  => 32
                 })
  end

    @json = (JSON.parse(@json1) + JSON.parse(@json2)).to_json

  end

ちなみに、ありがとうございます。アプリ内の近くの場所にマーカーを追加する方法を探していました:)

よろしく。

于 2013-03-13T14:12:01.237 に答える