As far as I can tell from the documentation and ReadMe for the gmaps4rails gem, you need to a model to set as acts_as_gmappable in order to use this wrapper.
In my case I am using simple a form_tag and text_field_tag elements in order to gather the addresses I want to display, and then I want to pass it through the wrapper in order to render the Google Map. I am not storing this gathered data in a database or model.
My questions are:
Can this be done with gmaps4rails? If yes can you direct me to an example of a model-less use case or give me any tips on how to do this?
If it can't be done with gmaps4rails, is there another gem/wrapper that would work? (I eventually want to show routes and directions)
I understand that I can use the original Google Maps JS V3 API, however I'm trying to keep it in Rails if possible because I'm a total newbie (business guy that decided to learn Rails and make a proto himself in order to attract a tech co-founder) and it seems like it'd be easier to use a wrapper than try to integrate with the API.
Thank you in advance for your help!
You could do this with gmaps4rails.
No need for acts_as_gmappable which is meant to geocode addresses.
Simply provide the view with something like:
#markers_json = [{lat: , lng:, description: }, {lat: , lng:, description: }].to_json
description will be displayed in infowindow.
Related
I'm trying to add custom functionality to my map where a user can filter out certain markers. Using simple jquery, I am to just find the marker using css selectors and do something like:
$('.marker').hide()
This works fine...however, when I zoom out, the marker is still considered there in the marker cluster count. I want to adjust the count to take into account that I hid the marker.
Any help would be appreciated. I'm not even sure how to access the marker cluster object as documented here:
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/docs/reference.html
Do I do something like:
handler.getCluster()
Thank you for your help!
I dont really understand your jQuery stuff here for google map markers...
You should use the existing methods on the objects returned by the addMarker(s) method:
.show()
.hide()
Anyway, to answer your primary question:
handler.clusterer
as usual the googleObject is available:
handler.clusterer.getServiceObject()
I'm trying to expose a search feature in rails. I want a user to be able to enter a string like name:"john" color:"blue" and get a list of ActiveRecord objects for some model that have a name attribute containing john and a color attribute containing blue. I'd also like them to be able to use and and or and parentheses e.g. name:"john" or color:"blue" or (name:"john" color:"blue") or name:"bill". Ideally they could also use things like age<20 where age is an numeric field. Is there a rails plugin that does this. I've was looking briefly at sphinx and ferret both of which seem to create an api for this but it was unclear whether they provided a clear text based option or if I would need to parse the search strings myself.
Ernie's Ransack gem is a good place to start.
You will have to provide an intermediate layer between your submitted form and the Ransack code (this would be a good idea anyway for security reasons) to convert strings from the format you desire to something Ransack can understand.
If you check the demo page and the documentation for the gem you'll find it's quite simple to create the sort of queries you're after.
Watch how GET requests are generated from the conditions you build and in your application replace the builder Ernie has in the demo with a single textfield accepting strings like (name:"john" color:"blue") or name:"bill". Do some pattern matching when this field is submitted and build a proper querystring to pass onto the Ransack gem.
Edit
For future questions like "what's a popular gem for ______?", check out The Ruby Toolbox. If Ransack doesn't suit your needs, perhaps a gem in the Rails Search category has what you're looking for. I personally use Ransack for exactly what you're describing; providing a custom query interface for my application's User model.
I'd suggest doing your own search class. I find that for each app I do, the needs of search change considerably and it's simple enough to create a search app that considers all the variables you might want in a search query, posed against any number of classes you want to search.
In your Search class, have it return a collection, in the order you desire, and the collection can be made up of object instances that the searcher may desire.
I'm looking for a search engine, which will let my users to search my website using syntax similar to this gmail's one.
My website is a map-based directory of restaurants and shops so it would be lovely to make it possible to search it using strings like those:
Restaurant's name city:Boston diet:vegetarian
Restaurant's name country:Belgium tags:fast-food
Restaurant's name country:Poland diet:vegan tags:pizza
etc...
Have you any idea what can i use to achieve such a functionality? I've browsed all of the solutions from ruby-toolbox but most of them requires to have some kind of special search server set up. I can do that on my VPS but at first i would love to hear your opinion which one is the most powerfull, dev-friendly and which one covers the functionality described above. Thank you in advance! :)
How about https://github.com/makandra/dusen gem?
It supports gmail-like token search!
You could try to use regexp to extract search params from request:
search_pairs = params[:search].scan(/([a-zA-Z]+):([a-zA-Z]+)/)
>> [ ['country', 'Poland'], ['diet', 'vegan'] ]
I'm having some trouble with in my MVC-View. The data for the listbox is passed by the controller and accessible via Model.templateList. So now I have to pass these data to the asp:listbox. Is there any way to do this or do I have to use some sort of DataProvider. What would be bad in terms of SoC. I considered using the Html-Helper Html.ListBox but I have no idea how to get actions like double-click and so on to work with it. Hope there are many smart people with some knowledge about this.
Thank you for reading
To bind to the list box you would using something like this
#Html.ListBox("ListBoxName", new SelectList(Model,"dataValueField", "dataTextField"));
with regards to the the actions you would need to use JavaScript. A google query like "listbox double click javascript" will help you get to the next level.
i am trying to get access to whitepages using YQL. Unfortunately i don't have much experience with opentables.
I was directed to the whitepages xml file at:
http://github.com/spullara/yql-tables/blob/c63212b2ac9db6feb77ae3cecace51ed52e08c01/whitepages/whitepages.search.xml
Does anyone know how to use this table to extract meaningful information using YQL?
Specifically, I'm not sure how to make a query in YQL using this table to search for a person's name.
Help?
Go to the YQL console http://developer.yahoo.com/yql/console/ and click Show Community Tables. That should make the list on the right much bigger, and will include your table.
have you tried to put
&env=http%3A%2F%2Fdatatables.org%2Falltables.env
at the end of your request?