photomix/public/javascripts/application.js

77 lines
3.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
}
$("#album_address").change( function () {
var geocoder = new GClientGeocoder()
//console.log( $("#album_address").val() )
geocoder.getLatLng( $("#album_address").val() , function(point) {
//console.log( point )
if ( point ) {
if (typeof map == "undefined") {
$('#map_canvas').show()
mapInitialize()
}
2009-07-06 15:41:19 +02:00
$('#album_latitude').val( point.lat() )
$('#album_longitude').val( point.lng() )
map.setCenter(new GLatLng( $('#album_latitude').val(), $('#album_longitude').val()), 13);
var marker = mapCreateMarker( { 'title' : $("#album_title").val(), 'address' : $("#album_address").val(), 'latitude': point.lat(), 'longitude' : point.lng() } );
map.addOverlay(marker);
}
else
{
$('#map_canvas').hide()
}
2009-07-06 15:41:19 +02:00
}
)
}
)
function mapInitialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setUIToDefault();
map.setCenter(new GLatLng( $('#album_latitude').val(), $('#album_longitude').val()), 13);
var marker = mapCreateMarker( { 'id' : $("#album_id").val(), 'title' : $("#album_title").val(), 'address' : $("#album_address").val(), 'latitude': $("#album_latitude").val(), 'longitude' : $("#album_longitude").val() } );
map.addOverlay(marker);
map.setCenter( new GLatLng( $("#album_latitude").val(), $("#album_longitude").val() ), 13 )
locations_on_map[ $("#album_id").val() ][0].openInfoWindowHtml( locations_on_map[ $("#album_id").val() ][1] )
}
}
function mapProcessData(data) {
var locations = eval('(' + data + ')');
for (var i=0; i<locations.length; i++) {
var marker = mapCreateMarker(locations[i].location )
if ( marker ) {
map.addOverlay( marker )
}
}
}
function mapCreateMarker(location) {
if ( !location.latitude || !location.longitude ) {
return false;
}
var marker = new GMarker( new GLatLng(parseFloat( location.latitude), parseFloat( location.longitude) ) )
var html = "<b>" + location.title + "</b> <br/>" + location.address + "<br /><br/>"
locations_on_map[location.id] = [marker, html]
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker
}
2009-05-25 21:39:43 +02:00
//$('div.scrollable').scrollable().click( $('#gallery ul').children().index( $('#gallery li.active') ) )
});