2014-03-12 1 views
1

내 웹 사이트의지도에서 일부 위치를 설정하고 있습니다. 나는 Google지도에 가서 내가 원하는 장소의 좌표를 얻는다. 그런 다음 위 숫자를 경도와 위도 필드에 넣어 마커를 배치합니다. 나는 나의 위치에지도를 검사하고 표식어는 소량에 의하여 밖으로 있고 나는 그것을 이해하지 않는다.gmaps4rails를 사용하십시오. 길고 위도가 낮은 좌표가 약간 있습니다. 이유가 확실하지 않습니다.

나는 경도와 위도에 대한 값을 수레로 잡고 있습니다.

위치의 차이입니다

다음

구글은 enter image description here

을 매핑하고 내 마커가 enter image description here

을 배치 위치를 볼 수있는이는 자사의 밖으로 좋은 비트지만 의해 위도와 경도를 Google지도에서 직접 입력 했으므로 여기에 표시되어야합니다.

여기 내 컨트롤러 코드

def show 
@store = Store.all 
@json = Store.all.to_gmaps4rails do |store, marker| 
    marker.infowindow render_to_string(:partial => "/stores/infowindow", :locals => { :store => store}) 
    marker.json ({:title => store.title}) 
    marker.json ({:latitude => store.latitude}) 
    marker.json ({:longitude => store.longitude}) 
    marker.json ({:street_line_one => store.street_line_one}) 
    marker.json ({:street_line_two => store.street_line_two}) 
    marker.json ({:town => store.town}) 
    marker.json ({:county => store.county}) 
    marker.json ({:opening_hours=>store.opening_hours}) 
    marker.json ({:phone_no=>store.phone_no}) 
    marker.json ({:email=>store.email}) 
    marker.picture ({ 
    'picture'=>view_context.image_path("map_marker.png"), 
    'width'=>79, 
    'height'=>74 
    }) 
end 

이며, 여기에 모델 코드 내 마커는 구글지도와 정확히 같은 장소에 떨어지는하지 왜 이해가 안

class Store < ActiveRecord::Base 
    acts_as_gmappable 

    attr_accessible :id, :street_line_one, :latitude, :longitude, :street_line_two, :town, :county, :country, :gmaps, :title, :opening_hours, :mainpage_images, :phone_no, :email 

    def gmaps4rails_address 
     "#{latitude}, #{longitude}" 
    end 
end 

에게 있습니다.

도움이 매우 감사합니다.

답변

1

하나 : 오프셋 기본

  • 또는 null입니다

    • 은 보석의 최신 버전을 사용 handler = Gmaps.build('Google', { markers: { maxRandomDistance: null } });

  • +0

    감사합니다, 정말의 창조자로서 귀하의 의견을 주셔서 감사합니다 보석, 정말 큰 도움이되었습니다. 보석을 업데이트 한 지금은 훨씬 더 가깝습니다. 마커는 매장이있는 곳으로 정확히 이동하지 않습니다. 마커가 도로에 붙을만한 이유가 있습니까? –

    +0

    님이 통과 한 좌표를 확인하지 않았습니다. 아마도 db는 여러분의 정밀도 중 일부를 제거합니다. – apneadiving

    +0

    예, 자리에 앉았습니다. 데이터베이스가 좌표의 마지막 소수점을 노크하고 있습니다. float 대신 십진수로 변경하거나이 문제를 해결할 수 있습니다. DB. 고맙다 apneadiving : D 조 –

    관련 문제