Change Map Center to current location

Discussion in 'GeoCraft WordPress Theme' started by dubloon2, Nov 16, 2015.

  1. dubloon2

    dubloon2 Member

    Joined:
    May 7, 2014
    Messages:
    30
    Likes Received:
    0
    Right now, the Map Center is calculated, (I think by finding the middle location of all Listings).

    I think it would be more useful for Users if the map starts with THEIR current location, so they could find listings in their closest proximity. Then they can zoom or pan to find whatever other listings they want.

    I have tried changing the map_search.php file, but so far have been unsuccessful in making this change.

    Can you recommend code for how to change this?

    Thanks,
     
  2. nitin

    nitin Guest

    Hi,

    Greetings from InkThemes,

    I would like you to know that at present this feature is not available in the theme which you are asking for.

    The users will get the listings irrespective of their current location and all the listings from every location will be displayed.

    Well, I will forward your query to the concerned department so that if possible, this feature could be integrated in further updates of the theme.

    Warm Regards!
    Nitin
    InkThemes.com
     
  3. dubloon2

    dubloon2 Member

    Joined:
    May 7, 2014
    Messages:
    30
    Likes Received:
    0
    Thank you for the response.

    I think the Google maps API has a command which provides the current location if available.

    I have tried to implement parts of this code into map_search.php file, but can't get it working.

    How much would you charge to have your engineers integrate this?

    var map;

    function initialize() {
    var myLatlng1 = new google.maps.LatLng(53.65914, 0.072050);

    var mapOptions = {
    zoom: 10,
    center: myLatlng1,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById('map'),
    mapOptions);

    if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
    initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    map.setCenter(initialLocation);
    });
    }
    }
    initialize();
     

Share This Page