Results 1 to 3 of 3

Thread: Remove "state / province" from Job Postings

  1. #1
    Thread Starter
    Veteran mstrong's Avatar
    Join Date
    Nov 2010
    Location
    Vancouver
    Posts
    284
    Thanks
    3
    Thanked 1 Time in 1 Post

    Remove "state / province" from Job Postings

    Greetings fellow Jobrollers,

    I have tried asking a few times - but no one seems to have the answer and I am thinking it has to be easy (I hope)

    I simply want my job postings to be the city / country without the province or state output. I am thinking it is in this code below (the google location map code) - but if anyone has done similiar or has advice - it would be GREATLY appreciated!

    Thanks to any / all who may assist!

    Mark (from Vancouver Canada)

    <?php
    /**
    * JobRoller Geoloaction functions
    * This file controls code for the Geolocation features.
    * Geolocation adapted from 'GeoLocation' plugin by Chris Boyd - http://geo.chrisboyd.net
    *
    *
    * @version 1.1
    * @author AppThemes
    * @package JobRoller
    * @copyright 2010 all rights reserved
    *
    */

    define('JR_DEFAULT_ZOOM', 1);

    function jr_clean_coordinate($coordinate) {
    $pattern = '/^(\-)?(\d{1,3})\.(\d{1,15})/';
    preg_match($pattern, $coordinate, $matches);
    return $matches[0];
    }

    function jr_reverse_geocode($latitude, $longitude) {

    $jr_gmaps_lang = get_option('jr_gmaps_lang');
    $jr_gmaps_region = get_option('jr_gmaps_region');

    $url = "http://maps.google.com/maps/api/geocode/json?latlng=".$latitude.",".$longitude."&language= ".$jr_gmaps_lang."&region=".$jr_gmaps_region." &sen sor=false";

    $result = wp_remote_get($url);
    $json = json_decode($result['body']);
    $city = '';
    $country = '';
    $short_country = '';
    $state = '';
    foreach ($json->results as $result)
    {
    foreach($result->address_components as $addressPart) {
    if((in_array('locality', $addressPart->types)) && (in_array('political', $addressPart->types)))
    $city = $addressPart->long_name;
    else if((in_array('administrative_area_level_1', $addressPart->types)) && (in_array('political', $addressPart->types)))
    $state = $addressPart->long_name;
    else if((in_array('country', $addressPart->types)) && (in_array('political', $addressPart->types))) {
    $country = $addressPart->long_name;
    $short_country = $addressPart->short_name;
    }
    }
    }

    if(($city != '') && ($state != '') && ($country != ''))
    $address = $city.', '.$state.', '.$country;
    else if(($city != '') && ($state != ''))
    $address = $city.', '.$state;
    else if(($state != '') && ($country != ''))
    $address = $state.', '.$country;
    else if($country != '')
    $address = $country;

    if ($country=='United Kingdom') $short_country = 'UK';

    if(($city != '') && ($state != '') && ($country != '')) {
    $short_address = $city;
    $short_address_country = $state.', '.$country;
    } else if(($city != '') && ($state != '')) {
    $short_address = $city;
    $short_address_country = $state;
    } else if(($state != '') && ($country != '')) {
    $short_address = $state;
    $short_address_country = $country;
    } else if($country != '') {
    $short_address = $country;
    $short_address_country = '';
    }

    return array(
    'address' => $address,
    'country' => $country,
    'short_address' => $short_address,
    'short_address_country' => $short_address_country
    );
    }

    function jr_geolocation_scripts() {
    $zoom = JR_DEFAULT_ZOOM;
    ?>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&amp;language=<?php echo get_option('jr_gmaps_lang') ?>&amp;region=<?php echo get_option('jr_gmaps_region') ?>"></script>


    <script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(function() {
    $j(document).ready(function() {

    var hasLocation = false;
    var center = new google.maps.LatLng(0.0,0.0);
    var postLatitude = '<?php global $posted, $job_details, $post; if (isset($posted['jr_geo_latitude'])) echo $posted['jr_geo_latitude']; elseif (isset($job_details->ID)) echo get_post_meta($job_details->ID, '_jr_geo_latitude', true); elseif (isset($post->ID)) echo get_post_meta($post->ID, '_jr_geo_latitude', true); ?>';
    var postLongitude = '<?php global $posted, $job_details; if (isset($posted['jr_geo_longitude'])) echo $posted['jr_geo_longitude']; elseif (isset($job_details->ID)) echo get_post_meta($job_details->ID, '_jr_geo_longitude', true); elseif (isset($post->ID)) echo get_post_meta($post->ID, '_jr_geo_longitude', true); ?>';

    if((postLatitude != '') && (postLongitude != '')) {
    center = new google.maps.LatLng(postLatitude, postLongitude);
    hasLocation = true;
    $j("#geolocation-latitude").val(center.lat());
    $j("#geolocation-longitude").val(center.lng());
    reverseGeocode(center);
    }

    var myOptions = {
    'zoom': <?php echo $zoom; ?>,
    'center': center,
    'mapTypeId': google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById('geolocati on-map'), myOptions);
    var marker = '';

    if((!hasLocation) && (google.loader.ClientLocation)) {
    center = new google.maps.LatLng(google.loader.ClientLocation.la titude, google.loader.ClientLocation.longitude);
    reverseGeocode(center);
    }
    else if(!hasLocation) {
    map.setZoom(1);
    }

    google.maps.event.addListener(map, 'click', function(event) {
    reverseGeocode(event.latLng);
    });

    var currentAddress;
    var customAddress = false;
    /*$j("#geolocation-address").click(function(){
    currentAddress = $j(this).val();
    if(currentAddress != '')
    $j("#geolocation-address").val('');
    });*/

    $j("#geolocation-load").click(function(){
    if($j("#geolocation-address").val() != '') {
    customAddress = true;
    currentAddress = $j("#geolocation-address").val();
    geocode(currentAddress);
    return false;
    } else {
    marker.setMap(null);
    marker = '';
    $j("#geolocation-latitude").val('');
    $j("#geolocation-longitude").val('');
    return false;
    }
    });

    $j("#geolocation-address").keyup(function(e) {
    if(e.keyCode == 13)
    $j("#geolocation-load").click();
    });


    function placeMarker(location) {
    if (marker=='') {
    marker = new google.maps.Marker({
    position: center,
    map: map,
    title:'Job Location'
    });
    }
    marker.setPosition(location);
    map.setCenter(location);
    if((location.lat() != '') && (location.lng() != '')) {
    $j("#geolocation-latitude").val(location.lat());
    $j("#geolocation-longitude").val(location.lng());
    }

    /*if(!customAddress || $j("#geolocation-address").val() == '') {
    customAddress = '';
    reverseGeocode(location);
    }*/
    }

    function geocode(address) {
    var geocoder = new google.maps.Geocoder();
    if (geocoder) {
    geocoder.geocode({"address": address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    placeMarker(results[0].geometry.location);
    reverseGeocode(results[0].geometry.location);
    if(!hasLocation) {
    map.setZoom(9);
    hasLocation = true;
    }
    }
    });
    }
    $j("#geodata").html(latitude + ', ' + longitude);
    }

    function reverseGeocode(location) {
    var geocoder = new google.maps.Geocoder();
    if (geocoder) {
    geocoder.geocode({"latLng": location}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {

    var address, city, country, state;

    for ( var i in results ) {

    var address_components = results[i]['address_components'];

    for ( var j in address_components ) {

    var types = address_components[j]['types'];
    var long_name = address_components[j]['long_name'];
    var short_name = address_components[j]['short_name'];

    if ( $j.inArray('locality', types)>=0 && $j.inArray('political', types)>=0 ) {
    city = long_name;
    }
    else if ( $j.inArray('administrative_area_level_1', types)>=0 && $j.inArray('political', types)>=0 ) {
    state = long_name;
    }
    else if ( $j.inArray('country', types)>=0 && $j.inArray('political', types)>=0 ) {
    country = long_name;
    }

    }

    }

    if((city) && (state) && (country))
    address = city + ', ' + state + ', ' + country;
    else if((city) && (state))
    address = city + ', ' + state;
    else if((state) && (country))
    address = state + ', ' + country;
    else if(country)
    address = country;

    $j("#geolocation-address").val(address);
    placeMarker(location);

    return true;

    /*if(results[1]) {
    var address = results[1].formatted_address;
    if(address == "")
    address = results[7].formatted_address;
    else {
    $j("#geolocation-address").val(address);
    placeMarker(location);
    }
    }*/
    }

    });
    }
    return false;
    }

    // Prevent form submission on enter key
    $j("#submit_form").submit(function(e) {
    if ($j("input:focus").attr("id")=='geolocation-address') return false;
    });

    });
    });
    </script>
    <?php
    }

  2. #2
    jomarkosabel's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    41,009
    Thanks
    170
    Thanked 3,409 Times in 3,280 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Please help our moderating team work more efficiently by not sending us support questions via PM. You can read more about how AppThemes support works here. However, you can send a PM to follow up and remind me if I missed your support request/thread.

    Thank you and have a nice day.

  3. #3
    Junior Member wdidan's Avatar
    Join Date
    Feb 2011
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: November 20th, 2012, 09:54 AM
  2. [SOLVED] Remove Total Views form the "Popular Ads Overall" widgets
    By ashplus10 in forum Help Using ClassiPress
    Replies: 4
    Last Post: September 18th, 2010, 05:00 PM
  3. Custom Fields remove "state"
    By aktiwers in forum Help Using ClassiPress
    Replies: 2
    Last Post: May 4th, 2010, 05:00 PM