photomix/public/javascripts/application.js

66 lines
2.1 KiB
JavaScript
Raw Normal View History

2009-05-25 21:39:43 +02:00
jQuery(function($) {
2009-06-03 21:30:09 +02:00
if ( $('.tag_list').length ) {
$('.tag_list').tagSuggest({
2009-05-25 21:39:43 +02:00
tags: $('#all_tags').val().split('\'')
})
}
var map, locations_on_map = new Array();
if ( $('#map_canvas').length && $('#album_latitude').val() > '' && $('#album_longitude').val() > '' ) {
2009-07-06 15:41:19 +02:00
mapInitialize()
$('#map_canvas').show()
2009-07-06 15:41:19 +02:00
}
2009-07-08 16:52:21 +02:00
$("#album_address").change( function() {
var geocoder = new google.maps.Geocoder()
var address = this.value
if (geocoder) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map.set_center(results[0].geometry.location)
mapCreateMarker( {
title: $('#album_title').val(),
address: results[0].formatted_address,
position: results[0].geometry.location
}
)
} else {
alert("No results found")
}
} else {
alert("Geocode was not successful for the following reason: " + status)
}
});
2009-07-06 15:41:19 +02:00
}
2009-07-08 16:52:21 +02:00
})
function mapInitialize() {
var latlng = new google.maps.LatLng($('#album_latitude').val(), $('#album_longitude').val());
var myOptions = {
zoom: 13,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
2009-07-06 15:41:19 +02:00
}
2009-07-08 16:52:21 +02:00
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions)
}
2009-07-06 15:41:19 +02:00
function mapCreateMarker(location) {
2009-07-08 16:52:21 +02:00
var marker = new google.maps.Marker({
map: map,
position: location.position,
title: location.title
})
var infowindow = new google.maps.InfoWindow({
content: '<b>' + location.title + '</b><br/>' + location.address
})
2009-05-25 21:39:43 +02:00
2009-07-08 16:52:21 +02:00
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker)
})
}
})