var currentPage = 0; var map; var geoXml; var icon; var currentMarker; var currentIndex; var BmapPointsVisible = []; for (i=0;i < BmapPoints.length;i++) { if (BmapPoints[i].lat != 0 && BmapPoints[i].lng != 0) { BmapPointsVisible.push(BmapPoints[i]); } } function initialiseMap() { if (BmapPoints.length == 1) { var myOptions = { navigationControl: true, mapTypeControl:true, scaleControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP, zoom: 15, center: new google.maps.LatLng(BmapPoints[0].lat, BmapPoints[0].lng), navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL } }; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); } else { var myStandartOptions = { navigationControl: true, mapTypeControl:true, scaleControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP, zoom: 2, center: new google.maps.LatLng(18.28125, 7.54681317351514), navigationControlOptions: { style: google.maps.NavigationControlStyle.DEFAULT } }; map = new google.maps.Map(document.getElementById('map_canvas'), myStandartOptions); } //map.clearOverlays(); var to = 8; if (BmapPoints.length < 8) { to = BmapPoints.length; } for (var i=0; i < to ;i++) { if (BmapPoints[i].lat != 0 && BmapPoints[i].lng != 0) { createMarker(new google.maps.LatLng(BmapPoints[i].lat, BmapPoints[i].lng), BmapPoints[i], i); } } } function createMarker(point, BmapPoint, index) { //icon = new GIcon(); //icon.image = "http://www.streetartlocator.com/icon/icon-"+ BmapPoint.type +".png"; //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; //icon.shadowSize = new GSize(22, 20); //icon.iconAnchor = new GPoint(6, 20); //icon.infoWindowAnchor = new GPoint(5, 1); var image = new google.maps.MarkerImage("http://www.streetartlocator.com/icon/icon-"+ BmapPoint.type +".png", // This marker is 20 pixels wide by 32 pixels tall. new google.maps.Size(18, 18), // The origin for this image is 0,0. new google.maps.Point(0, 0), // The anchor for this image is the base of the flagpole at 0,32. new google.maps.Point(0, 0)); var marker = new google.maps.Marker({'draggable':true, 'position':point, 'map':map, 'icon':image, 'title':BmapPoint.title}); var html = '
\ Edit this location \
'; var infowindow = new google.maps.InfoWindow( { content: html, size: new google.maps.Size(50,50) }); google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); }); google.maps.event.addListener(marker, "dragstart", function() { infowindow.close(); }); google.maps.event.addListener(marker, "dragend", function() { infowindow.open(map,marker); savePosInDB(marker, BmapPoint.id + '_-1'); currentMarker = marker; currentIndex = index; //console.log(currentIndex); //addFormListener(currentIndex); }); google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); currentMarker = marker; currentIndex = index; }); //map.addOverlay(marker); } function fixBubbles() { if ($('.map_bubble').parent().height() > $('.map_bubble').parent().parent().height() ) { $('.map_bubble').parent().parent().height($('.map_bubble').parent().height()); } } /*function addFormListener(id) { var BmapPoint = BmapPoints[id]; //console.log(BmapPoint); var r = 0; for (r=0;r < BmapPoint.photos.length; r++) { $('#aForm' + BmapPoint.photos[r].photo_id + "_" + r ).ajaxForm({ beforeSubmit: function(a,f,o) { //console.log('submit'); //console.log(a); //console.log(f); //console.log(o); o.dataType = 'json'; $(f).find('.f1_upload_process').show(); $(f).find('.f1_upload_form').hide(); }, success: function(data) { //console.log(data); var photos = []; for (var y=0; y < data.length; y++) { if (data[y].result == 1) { //console.log('saving'); saveDataInDB(data[y].new_name, data[y].idz); } else if (data[y].result == 3) { alert('The size of the file you attempted to upload is too large!'); } else { alert('There was an error during file upload!'); } } } }); } } var aSuccess = 0; function stopUpload(success, new_file_name, idz) { var result = ''; aSuccess = success; if (success == 1) { result = 'The file was uploaded successfully!<\/span>

'; saveDataInDB(new_file_name, idz); } else if (success == 3) { alert('The size of the file you attempted to upload is too large!'); } else { alert('There was an error during file upload!'); } return true; }*/ function savePosInDB(marker, idz) { var id = idz.split("_"); var point = marker.getLatLng(); var lat = point.lat(); var lng = point.lng(); var url = "lat=" + lat + "&lng=" + lng + "&id=" + id[0]; $.ajax({ type:"POST", url:"update_sql.php", data:url, success: function(data) { data = jQuery.trim(data); if (data != "100") { BmapPoints[currentIndex].lng = lng; BmapPoints[currentIndex].lat = lat; } else { alert ('Please try later'); } } }); } /*function saveDataInDB(new_file_name, idz) { var id = idz.split("_"); var newfile = escape(new_file_name); var oldfile = $("#img_"+idz).attr("src"); oldfile = oldfile.replace(basepath, ""); oldfile = oldfile.replace("thumb/", ""); var video = ''; if ($('#f1_upload_form_' + idz + ' input[name="video"]').length != 0) { video = escape($('#f1_upload_form_' + idz + ' input[name="video"]').val()); } var url = "newfile=" + newfile + "&oldfile=" + oldfile + "&id=" + id[0] + "&embed=" + video; // photo; $.ajax({ type:"POST", url:"update_sql.php", data:url, success: function(data) { console.log(data); data = jQuery.trim(data); if (data != "100") { $("#img_" + idz).parent().parent().css('width', ''); $("#img_"+idz).attr("src", basepath + "thumb/" + new_file_name); BmapPoints[currentIndex].photos[id[1]] = basepath + "thumb/" + new_file_name; $("#f1_upload_process_"+idz).hide(); $("#img_"+idz).show(); $("#img_" + idz).parent().parent().siblings().toggle("slide", { direction: "right" }, 2000); } else { alert ('Please try later'); } } }); }*/