2011-08-02 13:25:37 +02:00
|
|
|
|
|
|
|
jQuery(document).ready(function($) {
|
|
|
|
// $() will work as an alias for jQuery() inside of this function
|
|
|
|
var map_canvas = $('.map_canvas');
|
|
|
|
var g_map;
|
2011-08-02 23:07:53 +02:00
|
|
|
var or_latln= new google.maps.LatLng(WP_Params.lat, WP_Params.lng);
|
|
|
|
var or_maptype;
|
|
|
|
switch (WP_Params.mapType){
|
|
|
|
case 'ROADMAP':
|
|
|
|
or_maptype = google.maps.MapTypeId.ROADMAP;
|
|
|
|
break;
|
|
|
|
case 'HYBRID':
|
|
|
|
or_maptype = google.maps.MapTypeId.HYBRID;
|
|
|
|
break;
|
|
|
|
case 'TERRAIN':
|
|
|
|
or_maptype = google.maps.MapTypeId.TERRAIN;
|
|
|
|
break;
|
|
|
|
case 'SATELLITE':
|
|
|
|
or_maptype = google.maps.MapTypeId.SATELLITE;
|
|
|
|
break;
|
|
|
|
}
|
2011-08-02 13:25:37 +02:00
|
|
|
map_canvas.after('<div id="hidden-markers-content" style ="display:hidden;"></div>')
|
|
|
|
info_w = false;
|
|
|
|
if (map_canvas){
|
2011-08-02 23:07:53 +02:00
|
|
|
markers_map = $('.map_canvas').gmap({'center': or_latln, 'zoom' : Number(WP_Params.zoom),'mapTypeId': or_maptype, 'callback': function(map){
|
2011-08-02 13:25:37 +02:00
|
|
|
g_map=map;
|
|
|
|
info_w = new google.maps.InfoWindow({content: ' '});
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
action: 'soundmap_JSON_load_markers'
|
|
|
|
};
|
|
|
|
$.post(WP_Params.ajaxurl, data, function(response) {
|
|
|
|
result = $.parseJSON(response);
|
2011-08-22 10:20:44 +02:00
|
|
|
if (result){
|
2011-08-02 13:25:37 +02:00
|
|
|
$.each( result, function(i, m) {
|
|
|
|
$('.map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(m.lat, m.lng) }).data('postid', m.id).click(function(){
|
|
|
|
id=$(this).data('postid');
|
|
|
|
marker = $(this).get(0);
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
action: 'soundmap_load_infowindow',
|
|
|
|
marker: id
|
|
|
|
};
|
|
|
|
|
|
|
|
$.post(WP_Params.ajaxurl, data, function(response){
|
|
|
|
info_w.close();
|
|
|
|
$("#hidden-markers-content").append(response);
|
|
|
|
info_w.setContent($("#hidden-markers-content").children().get(0));
|
|
|
|
info_w.open(g_map, marker);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
2011-08-22 10:20:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2011-08-02 13:25:37 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|