Plugin Directory

Changeset 1559880


Ignore:
Timestamp:
12/22/2016 03:06:18 PM (9 years ago)
Author:
ardsoft
Message:

Cluster update

Location:
dml-easy-map/trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • dml-easy-map/trunk/dmlmap.php

    r1556050 r1559880  
    202202        wp_localize_script( 'dmlmap-js-public', 'dml_pub_php_links', $dataPubToBePassed );
    203203        wp_enqueue_script('dmlmap-js-public');
     204
     205        wp_register_script('dmlmap-clusterjs', plugins_url('/js/markerclusterer.js',__FILE__), array('jquery'),'',true);
     206        wp_enqueue_script('dmlmap-clusterjs');
    204207       
    205208        wp_register_script('dmlmap-bootstrapjs-public', plugins_url('/js/bootstrap.min.js',__FILE__), array('jquery'),'',true);
     
    235238        wp_localize_script( 'dmlmap-js-private', 'dml_php_links', $dataToBePassed );
    236239        wp_enqueue_script('dmlmap-js-private');
     240
     241        wp_register_script('dmlmap-clusterjs', plugins_url('/js/markerclusterer.js',__FILE__), array('jquery'),'',true);
     242        wp_enqueue_script('dmlmap-clusterjs');
    237243
    238244        wp_register_script('dmlmap-bootstrapjs-public', plugins_url('/js/bootstrap.min.js',__FILE__), array('jquery'),'',true);
     
    461467                $args = array(
    462468                        'post_type'     =>  'dml_location',
    463                         'numberposts'   => -1,
     469                        'posts_per_page' => -1,
    464470                        'orderby'       => 'ID',
    465471                        'order'         => 'ASC',
     
    857863    $dmlLinkSearch = dml_search_link_string($needle);
    858864
    859     if ( $dmlLinkSearch == 1 && is_plugin_active('dmlmap/dmlmap.php') ):
     865    if ( $dmlLinkSearch == 1 && is_plugin_active('dml-easy-map/dmlmap.php') ):
    860866   
    861867        // get the wp version
  • dml-easy-map/trunk/js/private/dmlmap.js

    r1556050 r1559880  
    1616
    1717    3. MARKER FUNCTIONS
    18         3.1 - dml_delete_Markers()          Adds temporary marker when clicked on the map
     18        3.1 - dml_add_Cluster_Markers()     Adds temporary marker when clicked on the map
    1919        3.2 - dml_add_Marker()              Creates new pin on the map
    2020        3.3 - dml_delete_Markers()
     
    196196// 2.4  - Load Google Map with customized style if selected
    197197function dml_load_JSON(myStyleNu) {   
    198         var myStyleFile = dml_php_links.UrlofPlugin + "/dmlmap/styles/style" + myStyleNu + ".json";
     198        var myStyleFile = dml_php_links.UrlofPlugin + "/dml-easy-map/styles/style" + myStyleNu + ".json";
    199199        var xobj = new XMLHttpRequest();
    200200        xobj.overrideMimeType("application/json");
     
    278278
    279279    // Adds a markers at the map.
    280     dml_add_Markers();
     280    dml_add_Cluster_Markers();
    281281}
    282282
    283283// 3    - MARKER FUNCTIONS
    284284// 3.1  - Adds temporary marker when clicked on the map
    285 function dml_add_Markers() {
     285function dml_add_Cluster_Markers() {
    286286    var infowindow = new google.maps.InfoWindow({});
    287287    var marker, i;
    288     var imagePath = dml_php_links.UrlofPlugin + "/dmlmap/icons/";
    289     for (i = 1; i < dmlmyArr.length; i++) {
    290 
    291         marker = new google.maps.Marker({
    292             position: new google.maps.LatLng(dmlmyArr[i].dml_lat, dmlmyArr[i].dml_lng),
    293             map: dmlmap,
    294             icon: imagePath + dmlmyArr[i].dml_zoom_icon + ".png"
    295         });
    296        
    297         google.maps.event.addListener(marker, 'click', (function (marker, i) {
    298             return function () {
    299                 if (jQuery("#dmlmyMap1Edit").html() == 1) {
    300                    
    301                     infowindow.setContent('<strong><span id="' + dmlmyArr[i].dml_id + '_H">' + dmlmyArr[i].dml_height_title + '</span></strong><br><span id="' + dmlmyArr[i].dml_id + '_D">' + dmlmyArr[i].dml_maptype__markerdesc + '</span><br><div onclick="dml_Edit_Marker_Description(' + dmlmyArr[i].dml_id + ');" class="button btn btn-success btn-sm fontawesome-pencil"></div><div onclick="dml_Delete_Db_Marker(' + dmlmyArr[i].dml_id + ');" class="btn btn-danger btn-sm fontawesome-trash" style="margin-left:2px;"></div><div onclick="dml_Fill_Marker_Settings(' + dmlmyArr[i].dml_id + ');" class="btn btn-primary btn-sm fontawesome-picture" style="margin-left:2px;"></div><div class="btn btn-default btn-sm" style="display:none;"><span class="badge">' + dmlmyArr[i].dml_id + '</span></div>');
    302 
    303                 } else {
    304                     infowindow.setContent('<strong>' + dmlmyArr[i].dml_height_title + '</strong><br>' + dmlmyArr[i].dml_maptype__markerdesc + '<br>');
     288    var imagePath = dml_php_links.UrlofPlugin + "/dml-easy-map/icons/";
     289
     290    var dmlClusterArr = [];
     291   
     292    for (var i = 0; i < dmlmyArr.length; i++) {
     293        if (dmlmyArr[i].dml_record_type != "M") {
     294            dmlClusterArr.push({
     295                dml_id: dmlmyArr[i].dml_id
     296            });
     297        }
     298    }
     299    var markers = dmlClusterArr.map(function(location, i) {
     300            marker = new google.maps.Marker({
     301                position: new google.maps.LatLng(dmlmyArr[i+1].dml_lat, dmlmyArr[i+1].dml_lng),
     302                map: dmlmap,
     303                icon: imagePath + dmlmyArr[i+1].dml_zoom_icon + ".png"
     304            });
     305           
     306            google.maps.event.addListener(marker, 'click', (function (marker, i) {
     307                return function () {
     308                    if (jQuery("#dmlmyMap1Edit").html() == 1) {
     309                       
     310                        infowindow.setContent('<strong><span id="' + dmlmyArr[i+1].dml_id + '_H">' + dmlmyArr[i+1].dml_height_title + '</span></strong><br><span id="' + dmlmyArr[i+1].dml_id + '_D">' + dmlmyArr[i+1].dml_maptype__markerdesc + '</span><br><div onclick="dml_Edit_Marker_Description(' + dmlmyArr[i+1].dml_id + ');" class="button btn btn-success btn-sm fontawesome-pencil"></div><div onclick="dml_Delete_Db_Marker(' + dmlmyArr[i+1].dml_id + ', 1);" class="btn btn-danger btn-sm fontawesome-trash" style="margin-left:2px;"></div><div onclick="dml_Fill_Marker_Settings(' + dmlmyArr[i+1].dml_id + ');" class="btn btn-primary btn-sm fontawesome-picture" style="margin-left:2px;"></div><div class="btn btn-default btn-sm" style="display:none;"><span class="badge">' + dmlmyArr[i+1].dml_id + '</span></div>');
     311
     312                    } else {
     313                        infowindow.setContent('<strong>' + dmlmyArr[i+1].dml_height_title + '</strong><br>' + dmlmyArr[i+1].dml_maptype__markerdesc + '<br>');
     314                    }
     315                    infowindow.open(dmlmap, marker);
    305316                }
    306                 infowindow.open(dmlmap, marker);
    307             }
    308         })(marker, i));
    309 
    310         dmlDbMarkers.push(marker);
    311     }
    312 
     317            })(marker, i));
     318
     319            dmlDbMarkers.push(marker);
     320       
     321            return marker;
     322     });
     323   
     324    var clusterStyles = [
     325    {
     326        textColor: 'black',
     327        url: dml_php_links.UrlofPlugin + '/dml-easy-map/icons/m1.png',
     328        height: 52,
     329        width: 53,
     330        textSize: 12
     331    },
     332    {
     333        textColor: 'black',
     334        url: dml_php_links.UrlofPlugin + '/dml-easy-map/icons/m2.png',
     335        height: 56,
     336        width: 55,
     337        textSize: 12
     338    },
     339    {
     340        textColor: 'black',
     341        url: dml_php_links.UrlofPlugin + '/dml-easy-map/icons/m3.png',
     342        height: 66,
     343        width: 65,
     344        textSize: 12
     345    }
     346    ];
     347    var mcOptions = {
     348        gridSize: 50,
     349        styles: clusterStyles,
     350        maxZoom: 15
     351    };
     352    var markerCluster = new MarkerClusterer(dmlmap, markers, mcOptions);
     353    dmlClusterArr = [];
    313354}
    314355// 3.2  - Creates new pin on the map
     
    465506        jQuery("#dmlOpt" + mySelectedStyle).attr("selected", "selected");
    466507        jQuery("#dmlSelectedStyleHolder").html(mySelectedStyle);
    467         jQuery("#dmlSelectedStyleThmb").html("<div class='input-group'><img src='" + dml_php_links.UrlofPlugin + "/dmlmap/styles/thmbs/" + mySelectedStyle + ".png' /></div>");
     508        jQuery("#dmlSelectedStyleThmb").html("<div class='input-group'><img src='" + dml_php_links.UrlofPlugin + "/dml-easy-map/styles/thmbs/" + mySelectedStyle + ".png' /></div>");
    468509       
    469510        //SETTINGS SAVE PARAMETER
     
    489530    //var myiconTempList;
    490531    for (var i = 1; i < 112; i++) {
    491         jQuery('#dmlIconList').append("<img onclick='dml_Select_One_icon(" + i + ");' src='" + dml_php_links.UrlofPlugin + "/dmlmap/icons/" + i + ".png' title='" + i + "' style='float:left;' />");
     532        jQuery('#dmlIconList').append("<img onclick='dml_Select_One_icon(" + i + ");' src='" + dml_php_links.UrlofPlugin + "/dml-easy-map/icons/" + i + ".png' title='" + i + "' style='float:left;' />");
    492533    }
    493534    jQuery("#dmlSettingsDiv").modal("toggle");
     
    593634function dml_Change_Map_Type(myStyleNu) {
    594635    jQuery("#dmlSelectedStyleHolder").html(myStyleNu);
    595     jQuery("#dmlSelectedStyleThmb").html("<div class='input-group'><img src='" + dml_php_links.UrlofPlugin + "/dmlmap/styles/thmbs/" + myStyleNu + ".png' /></div>");
     636    jQuery("#dmlSelectedStyleThmb").html("<div class='input-group'><img src='" + dml_php_links.UrlofPlugin + "/dml-easy-map/styles/thmbs/" + myStyleNu + ".png' /></div>");
    596637    dmlmyArr[0].dml_fill_color  = myStyleNu;
    597638   
     
    613654// 5.3  - Sets icon ID when a new icon selected for the marker
    614655function dml_Select_One_icon(myId) {
    615     var mySelectionText = "<img src='" + dml_php_links.UrlofPlugin + "/dmlmap/icons/" + myId + ".png' /> You selected this icon.";
     656    var mySelectionText = "<img src='" + dml_php_links.UrlofPlugin + "/dml-easy-map/icons/" + myId + ".png' /> You selected this icon.";
    616657    jQuery("#dmlMySelectediconText").html(mySelectionText);
    617658    jQuery("#dmlMySelectediconID").html(myId);
  • dml-easy-map/trunk/js/public/dmlmap.js

    r1556050 r1559880  
    143143// 2.4  - Load Google Map with customized style if selected
    144144function dml_load_JSON(myStyleNu) {   
    145         var myStyleFile = dml_pub_php_links.UrlofPubPlugin + "/dmlmap/styles/style" + myStyleNu + ".json";
     145        var myStyleFile = dml_pub_php_links.UrlofPubPlugin + "/dml-easy-map/styles/style" + myStyleNu + ".json";
    146146        var xobj = new XMLHttpRequest();
    147147        xobj.overrideMimeType("application/json");
     
    195195
    196196    // Adds a markers at the map.
    197     dml_add_Markers();
     197    dml_add_Cluster_Markers();
    198198}
    199199
     
    201201// 3    - MARKER FUNCTIONS
    202202// 3.1  - Adds temporary marker when clicked on the map
    203 function dml_add_Markers() {
     203function dml_add_Cluster_Markers() {
    204204    var infowindow = new google.maps.InfoWindow({});
    205205    var marker, i;
    206     var imagePath = dml_pub_php_links.UrlofPubPlugin + "/dmlmap/icons/";
    207     for (i = 1; i < dmlmyArr.length; i++) {
    208 
    209         marker = new google.maps.Marker({
    210             position: new google.maps.LatLng(dmlmyArr[i].dml_lat, dmlmyArr[i].dml_lng),
    211             map: dmlmap,
    212             icon: imagePath + dmlmyArr[i].dml_zoom_icon + ".png"
    213         });
     206    var imagePath = dml_pub_php_links.UrlofPubPlugin + "/dml-easy-map/icons/";
     207
     208    var dmlClusterArr = [];
     209   
     210    for (var i = 0; i < dmlmyArr.length; i++) {
     211        if (dmlmyArr[i].dml_record_type != "M") {
     212            dmlClusterArr.push({
     213                dml_id: dmlmyArr[i].dml_id
     214            });
     215        }
     216    }
     217   
     218    var markers = dmlClusterArr.map(function(location, i) {
     219            marker = new google.maps.Marker({
     220                position: new google.maps.LatLng(dmlmyArr[i+1].dml_lat, dmlmyArr[i+1].dml_lng),
     221                map: dmlmap,
     222                icon: imagePath + dmlmyArr[i+1].dml_zoom_icon + ".png"
     223            });
     224           
     225            google.maps.event.addListener(marker, 'click', (function (marker, i) {
     226                return function () {
     227                    infowindow.setContent('<strong>' + dmlmyArr[i+1].dml_height_title + '</strong><br>' + dmlmyArr[i+1].dml_maptype__markerdesc + '<br>');
     228                    infowindow.open(dmlmap, marker);
     229                }
     230            })(marker, i));
     231           
     232            dmlDbMarkers.push(marker);
    214233       
    215         google.maps.event.addListener(marker, 'click', (function (marker, i) {
    216             return function () {
    217                
    218                 infowindow.setContent('<strong>' + dmlmyArr[i].dml_height_title + '</strong><br>' + dmlmyArr[i].dml_maptype__markerdesc + '<br>');
    219                 infowindow.open(dmlmap, marker);
    220             }
    221         })(marker, i));
    222 
    223         dmlDbMarkers.push(marker);
    224     }
    225 
     234            return marker;
     235     });
     236     var clusterStyles = [
     237    {
     238        textColor: 'black',
     239        url: dml_pub_php_links.UrlofPubPlugin + '/dml-easy-map/icons/m1.png',
     240        height: 52,
     241        width: 53,
     242        textSize: 12
     243    },
     244    {
     245        textColor: 'black',
     246        url: dml_pub_php_links.UrlofPubPlugin + '/dml-easy-map/icons/m2.png',
     247        height: 56,
     248        width: 55,
     249        textSize: 12
     250    },
     251    {
     252        textColor: 'black',
     253        url: dml_pub_php_links.UrlofPubPlugin + '/dml-easy-map/icons/m3.png',
     254        height: 66,
     255        width: 65,
     256        textSize: 12
     257    }
     258    ];
     259    var mcOptions = {
     260        gridSize: 50,
     261        styles: clusterStyles,
     262        maxZoom: 15
     263    };
     264    var markerCluster = new MarkerClusterer(dmlmap, markers, mcOptions);
     265    dmlClusterArr = [];
    226266}
    227267// 3.2  - Clear markers
Note: See TracChangeset for help on using the changeset viewer.