69 lines
2.8 KiB
JavaScript
69 lines
2.8 KiB
JavaScript
jQuery(function($) {
|
|
|
|
if ( $('.tag_list').length ) {
|
|
$('.tag_list').tagSuggest({
|
|
tags: $('#all_tags').val().split('\'')
|
|
})
|
|
}
|
|
|
|
if ( $('#map_canvas').length ) {
|
|
var map, locations_on_map = new Array();
|
|
mapInitialize()
|
|
}
|
|
|
|
$("#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 ) {
|
|
$('#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
|
|
{ alert('Unable to find address') }
|
|
}
|
|
)
|
|
}
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
//$('div.scrollable').scrollable().click( $('#gallery ul').children().index( $('#gallery li.active') ) )
|
|
}); |