I’ve come up with a new version of the Cartographer library that lets
you embed Google Maps into your Rails app with ease. It allows you to do
stuff like define your maps and markers in Ruby instead of getting your
fingers mucky with Javascript.
It doesn’t support the complete Google Maps API yet, but I’d say it’s
about 70% of the way there or so.
Anyway, if you think it would be fun/useful to play with GMaps, give it
a shot. It’s available as a plugin, so all you need is
script/plugin install -x
svn://dotsx.usc.edu/cartographer/branches/pnh/vendor/plugins/cartographer
Now i’m getting an uninitialized constant GOOGLE_MAPS_API_KEY, but I am
guessing this is because I haven’t put in my API key yet (mainly because
I
don’t have one.)
Since each API key can only be used per url, whats the best way to test
my
application on localhost w/o having an API key?
#1. Cartographer is useful, but I’m having a slight issue with the
markers.
Any space in the text is being converted to linebreaks. IE: “This is my
marker text” shows up as:
This
is
my
marker
text
in the bubble when I click on the marker icon. Ideally, I’d like to
render_to_string( :partial => ‘map/marker’ ) to generate marker bubble
HTML… which works except for the newline/linebreak problem.
#2. You can use geocoder.ushttp://geocoder.us to get coordinates from
US
addresses. They also have an API. No rails plugin that I know of yet.
Since each API key can only be used per url, whats the best way to test my
application on localhost w/o having an API key?
Depends on what you mean. You can view source and look at the
Javascript that Cartographer’s producing and see if it makes sense.
But that’d be kind of lame.
I assume you mean ‘test’ in the sense of ‘use the map that
Cartographer should be cajoling Google into producing for you’. If so,
you must have an API key. It won’t work otherwise.
And Google is happy to give you a key for http://localhost/, so if
that’s how you’re serving your app locally, then no worries.
in the bubble when I click on the marker icon. Ideally, I’d like to
render_to_string( :partial => ‘map/marker’ ) to generate marker bubble
HTML… which works except for the newline/linebreak problem.
I can’t duplicate this. Do actual ‘ ’ tags occur in the HTML? Could
you send me an example? An URL?
Is the scheme of storing API keys in a hash keyed on the hostname the
kind of thing that would people consider useful? I like it because I can
have a separate API key depending on if I deploy on my laptop via
webrick or on the production server in lighty. Would it be more useful
to store the API key in a separate file so that you can just edit the
file on a per-host basis?
Is the scheme of storing API keys in a hash keyed on the hostname the
kind of thing that would people consider useful? I like it because I can
have a separate API key depending on if I deploy on my laptop via
webrick or on the production server in lighty. Would it be more useful
to store the API key in a separate file so that you can just edit the
file on a per-host basis?
-Phil H.
i think code for this is in the (unforked) cartographer… great work
btw!
Is the scheme of storing API keys in a hash keyed on the hostname the
kind of thing that would people consider useful? I like it because I can
have a separate API key depending on if I deploy on my laptop via
webrick or on the production server in lighty. Would it be more useful
to store the API key in a separate file so that you can just edit the
file on a per-host basis?
Yes, that’s useful, to me at least. When using the old version of
Cartographer I had a helper that checked the host and provided the
appropriate API key; this is easier and neater. Storing the key
separately would be a nuisance. For instance, on the current project I
have a key for my laptop, a key for my staging server, a key for the
production server with a port (for almost-production testing), and a
key for the production server without a port. Keeping track of all of
those would be a pain.