Вопрос

I have been trying to get a custom use of gmaps4rails running, and I have the code set to display my string of json coordinates on the map, and the center on user IS working, I can zoom into my location from home, work and my phone. I just cannot get the js right to display an 'Im here' button on the map once permission is given.

here is the code I use for the map from gmaps4rails:

<%= gmaps(:map_options => {:detect_location => true, :center_on_user => true, :auto_zoom => false, :zoom => 12, :auto_adjust => true}, :markers => {:data => @json} ) %>

Thanks for any help!

EDIT Dec.6 after answer:

I am adding in the code for the callback as so:

        <script type="text/javascript" charset="utf-8">
         Gmaps.map.callback = function() {
          Gmaps.map.createMarker({Lat: Gmaps.map.userLocation.lat(),
                                  Lng: Gmaps.map.userLocation.lng(), 
                                  rich_marker: null, 
                                  marker_picture: "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/heart30.png"
                   })
                }
        </script>

and still not getting a response on the map. Is this a problem with my js coding? I'm not pro yet.

thanks!

Это было полезно?

Решение

You can do this:

Gmaps.map.createMarker({Lat: Gmaps.map.userLocation.lat(),
                        Lng: Gmaps.map.userLocation.lng(), 
                        rich_marker: null, 
                        marker_picture: ""
                       })

in the callback.


Notice you can pass the url of your desired marker.

BTW, you should create an issue on github if you feel like this is a useful feature.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top