# Dynamic map/image showing property rental availability

**URL:** <https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307>\
**Category:** Rails\
**Created:** [June 2, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307 "2008-06-02T20:32:56Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 2, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/1 "2008-06-02T20:32:56Z")

</div>

I’m working on a rails app for a campground that rents cabins and  
tenting spots. I’d like to show a map or image of their property with  
cabin icons or boxes or something that change color based on whether or  
not they’re rented.

Does anyone know how to do anything like this? Or even what to search  
for to find out more information about this type of thing? I tried  
‘dynamic maps’, but I’m just getting Google map mashup stuff.

Please help!

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 2, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/2 "2008-06-02T23:11:26Z")

</div>

It sounds really awesome. I too am working on a project with features  
such as this. I’m not sure what the BEST approach would be but if I  
were going to take on something like this I would probably take the  
map or image and slice it into smaller images. A database driven  
system would be awesome. However I’m not sure what the best approach  
would be via ror. I’m interested in this too. Keep in touch.

Ed

On Jun 2, 2:32 pm, Denise R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 2, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/3 "2008-06-02T23:11:26Z")

</div>

How about Layers on top of a map indicating the locations of rentals?

On Jun 2, 2:32 pm, Denise R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 2, 2008, 11:12pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/4 "2008-06-02T23:12:01Z")

</div>

I’m interested in this too. I’m sure it involves some database  
connectivity and a sliced up image. Let me know what you come up  
with.

Ed

On Jun 2, 2:32 pm, Denise R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 2, 2008, 11:36pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/5 "2008-06-02T23:36:14Z")

</div>

Denise R. wrote:

> I’m working on a rails app for a campground that rents cabins and  
> tenting spots. I’d like to show a map or image of their property with  
> cabin icons or boxes or something that change color based on whether or  
> not they’re rented.
> 
> Does anyone know how to do anything like this? Or even what to search  
> for to find out more information about this type of thing? I tried  
> ‘dynamic maps’, but I’m just getting Google map mashup stuff.
> 
> Please help!

Use a flat image of their campground as the background image of the main  
content div on the page. Then place images of cabins on top of that,  
using CSS to position them correctly on the map. The image you display  
will be either the “not rented” image or the “rented image” depending on  
the data you feed it. You could wrap the images in tags to make them  
clickable to some page of information.

 

Just off the top of my head, I’m no css expert, but I think something  
along the lines of …

 

views  
campground.html.erb

 
 \<%= render :partial =\> 'cabin\_image', :collection =\> @cabins %\>
 

\_cabin\_image.html.erb  
\<%= cabin\_image.rented? ? image\_tag(“cabin-rented”, :class =\>  
“cabin#{cabin\_image\_counter}”) : image\_tag(“cabin-not-rented”, :class =\>  
“cabin#{cabin\_image\_counter}”) %\>

 

controller should populate @cabins

 

cabin model should have  
def rented?  
blah  
end

 

css stylesheet should have  
div#campground {  
position: relative;  
background-image: url(‘images/campground\_map’);  
}

 

img.cabin1 {  
position: absolute;  
top: blah;  
left: blah;  
}

 

img.cabin2 {  
position: absolute;  
top: blah;  
left: blah;  
}

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 12:32am UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/6 "2008-06-03T00:32:32Z")

</div>

That was very helpful! In my situation I’m probably going to be using  
a state map with counties and a pop up layer as you hover the county.  
This was my thinking with it as well. What do you think for my  
application?

On Jun 2, 5:36 pm, Cayce B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 2:00am UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/7 "2008-06-03T02:00:22Z")

</div>

Eddie S. wrote:

> That was very helpful! In my situation I’m probably going to be using  
> a state map with counties and a pop up layer as you hover the county.  
> This was my thinking with it as well. What do you think for my  
> application?
> 
> On Jun 2, 5:36ï¿½pm, Cayce B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Everything in CSS is a block so county maps with irregular shapes become  
a bit more difficult. You could use image maps  
([http://www.wickham43.supanet.com/tutorial/imagemaps.html](http://www.wickham43.supanet.com/tutorial/imagemaps.html)) to get it  
just perfect, but what a load of work that is gonna be (mapping out all  
the coords).

Instead, personally, I would go for a small hoverable icon or text link  
in the middle of each county and when the user hovers that a nice AJAX-y  
popup comes up in the shape of the county or something with add’l info.  
Just a personal preference but I avoid imagemaps unless I absolutely  
have to use them.

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 4:36pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/8 "2008-06-03T16:36:29Z")

</div>

Eddie,  
You might want to look at google maps for that. I’ve heard that you can  
do a lot of groovy things with the api, but it didn’t really apply to my  
issue.

Cayce,  
Thanks so much for the specifics. This is a completely new puzzle for  
me. The details in your post will help a lot.

Denise

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/9 "2008-06-03T16:39:19Z")

</div>

Why are you averse to using google maps (look for the ym4r plugin)?

1. You get accurate maps, directions, your clients can search for  
restaurants and other stuff near the campsites, etc. Basically you  
get a ton of features for free.
2. Use different colored pins and icons to indicate taken/available  
campsites.
3. You get little pop-up dialogs with more information about each site  
that you can control.

You can even mark hiking trails, all kinds of stuff.

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/10 "2008-06-03T16:44:56Z")

</div>

Definitely not adverse, but I don’t think it will work for this case.  
This is a single camground - not multiple locations. It’s one big  
wooded area out in the middle of nowhere. One address separated into  
lots of individual slices by the owners.

Am I wrong? Would google maps still be a good solution?

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 5:56pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/11 "2008-06-03T17:56:49Z")

</div>

While it may workfor what I am looking to do (a directory of an entire  
state and all counties), it probably wouldn’t work for Denises  
application. I am envisioning something like the Disney World iPhone  
web app for this situation…  
[http://www.wdwpinpoint.com/iphone/mk/index.jsp](http://www.wdwpinpoint.com/iphone/mk/index.jsp)

On Jun 3, 10:44 am, Denise R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/12 "2008-06-03T19:30:34Z")

</div>

I created something similar (not online now) to show exhibit booths for  
a  
conference floor plan.

The original map was created in Illustrator with each booth as an image  
map  
area. The resulting html was used to create the left, top, height, and  
width  
(this is not exactly how it came out of illustrator). Most booths were  
squares.

There was a special layout template that had a background image of the  
map  
with all the booths removed.

The code below drew a block over each booth with a colored div. I am  
sure it  
could be done cleaner but this did work in Firefox (not cross browser  
tested).

\<% for booth in @booths %\>

 

 \<%end%\>

Sunny

On Tue, Jun 3, 2008 at 11:55 AM, Eddie S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 7:50pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/13 "2008-06-03T19:50:00Z")

</div>

Are any of your examples online to view? Thanks, Eddie

---

<div class="post-metadata">

**Author:** ![gorgeoussoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@gorgeoussoul](https://www.ruby-forum.com/u/gorgeoussoul)\
**Post date:** [June 3, 2008, 7:26pm UTC](https://www.ruby-forum.com/t/dynamic-map-image-showing-property-rental-availability/139307/14 "2008-06-03T19:26:22Z")

</div>

Denise R. wrote:

> Definitely not adverse, but I don’t think it will work for this case.  
> This is a single camground - not multiple locations. It’s one big  
> wooded area out in the middle of nowhere. One address separated into  
> lots of individual slices by the owners.
> 
> Am I wrong? Would google maps still be a good solution?

No I think you’re right on for your app - Google maps not really  
applicable.
