New markers with shadows

This commit is contained in:
Erik Michaels-Ober 2011-03-01 00:20:55 -08:00
parent 93d5992289
commit 46a79f2c66
5 changed files with 42 additions and 23 deletions

View File

@ -11,37 +11,56 @@
var map;
var latlng = new google.maps.LatLng(<%= @lat %>, <%= @lng %>);
var myOptions = {
mapTypeControl: false,
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_CENTER
},
zoom: <%= @zoom %>,
zoomControl: false,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var redMarker = '/images/markers/red.png';
var greenMarker = '/images/markers/green.png';
var openInfoWindow;
var formString = '<%= render(:partial => "adoption_form").gsub("\n", "") %>'
<% @hydrants.each do |hydrant| %>
<% if user = hydrant.user %>
var contentString = '<%= render(:partial => "user_profile", :locals => {:user => user}).gsub("\n", "") %>'
<% else %>
var contentString = formString;
<% end %>
var h<%= hydrant.id %>LatLng = new google.maps.LatLng(<%= hydrant.lat %>, <%= hydrant.lng %>);
var h<%= hydrant.id %>Marker = new google.maps.Marker({
position: h<%= hydrant.id %>LatLng,
function addMarker(point, color, contentString) {
var image = new google.maps.MarkerImage(color,
new google.maps.Size(25.0, 44.0),
new google.maps.Point(0, 0),
new google.maps.Point(12.0, 22.0)
);
var shadow = new google.maps.MarkerImage('/images/markers/shadow.png',
new google.maps.Size(48.0, 44.0),
new google.maps.Point(0, 0),
new google.maps.Point(12.0, 22.0)
);
var marker = new google.maps.Marker({
position: point,
map: map,
icon: <%= hydrant.user_id ? "greenMarker" : "redMarker" %>
});
var h<%= hydrant.id %>InfoWindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(h<%= hydrant.id %>Marker, 'click', function() {
if(openInfoWindow) {
openInfoWindow.close();
}
h<%= hydrant.id %>InfoWindow.open(map, h<%= hydrant.id %>Marker);
openInfoWindow = h<%= hydrant.id %>InfoWindow;
});
icon: image,
shadow: shadow
});
var infoWindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
if(openInfoWindow) {
openInfoWindow.close();
}
infoWindow.open(map, marker);
openInfoWindow = infoWindow;
});
}
<% @hydrants.each do |hydrant| %>
point = new google.maps.LatLng(<%= hydrant.lat %>, <%= hydrant.lng %>);
color = <%= hydrant.user_id ? "'/images/markers/green.png'" : "'/images/markers/red.png'" %>;
<% if user = hydrant.user %>
contentString = '<%= render(:partial => "user_profile", :locals => {:user => user}).gsub("\n", "") %>'
<% else %>
contentString = formString;
<% end %>
addMarker(point, color, contentString);
<% end %>
$('.box input[type="radio"]').live('click', function() {
var self = $(this);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB