{
$sql = "SELECT * FROM " . GLM_MEMBERS_COUNTY_MAP_PLUGIN_DB_PREFIX . 'areas';
$areas = $this->wpdb->get_results($sql);
+ $args = array(
+ 'sort_order' => 'asc',
+ 'sort_column' => 'post_title',
+ 'hierarchical' => 0,
+ 'post_type' => 'page',
+ 'post_status' => 'publish'
+ );
+ $results = get_pages($args);
+ foreach($results as $page){
+ $pages[$page->ID]['name'] = $page->post_title;
+ $pages[$page->ID]['url'] = get_permalink($page->ID);
+ }
wp_enqueue_style('admin-css', GLM_MEMBERS_COUNTY_MAP_PLUGIN_URL . 'css/front.min.css');
// Compile template data
$templateData = array(
- 'assets' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_URL . 'assets/',
- 'areas' => $areas
+ 'assets' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_URL . 'assets/',
+ 'areas' => $areas,
+ 'pages' => $pages
);
-
+
// Return status, any suggested view, and any data to controller
return array(
'status' => true,
<script>
jQuery(function($){
+
// Create map with default center and size
var countyMap = L.map('area-map').setView([46.5, -87.0], 8);
var countiesDirectory = '{$assets}/counties/';
* for Longitude to move link to the left.
* "url" is added to the baseCountyUrl to generate the link address for a county
*/
- var areas = {$areas|json_encode};
- console.log(areas);
+ var areas = {$areas|json_encode};
+ var pages = {$pages|json_encode};
+
var upperMI = {
'Alger': {literal} {latOffset: -0.10, lonOffset: -0.40, url: 'county=Alger'},{/literal}
'Baraga': {literal} {latOffset: -0.10, lonOffset: -0.10, url: 'county=Baraga'},{/literal}
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
+
}
// Mouse out event handler
// For each UP county
var countyLayer;
$.each(upperMI, function(county, countyData) {
-
+ var page = "#";
+ var location = areas.filter( function(area){
+ return area.area_name == county;
+ })
+ location = location[0];
+ if(parseInt(location.page_id)){
+ page = pages[location.page_id]['url'];
+ }
// Get the GeoJson file for this county
$.get(countiesDirectory + county + '.GeoJson', function(countyFile) {
// Get center of the county and add offsets
var center = countyLayer.getBounds().getCenter();
var center = new L.LatLng(center.lat + countyData.latOffset, center.lng + countyData.lonOffset);
-
+
// Create Div type icom for county names
var countyNameIcon = L.divIcon({
className: 'county-name',
- html: '<a href="' + baseCountyUrl + countyData.url + '">' + county + '</a>'
+ html: '<a class="area-label ' + county +'" href="' + page + '">' + county + '</a>'
});
// use county name icon as marker using center location calculated above.
}
});
});
-</script>
\ No newline at end of file
+</script>
+<style>
+ /* .area-label{
+ position: relative;
+ }
+ .area-label.Houghton{
+ right: 40px;
+ bottom: 25px;
+ } */
+</style>
\ No newline at end of file