Jump to content

david@shapes.fr

Members
  • Content Count

    15
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by david@shapes.fr


  1. Hello,

     

    I'm trying to GeoLocate visitor in the ajax map.

     

    I checked this tutorial :

    http://www.paulund.co.uk/how-to-use-geolocation-api-with-google-maps

     

    I managed to GeoLocate the user, by adding :

     

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
    <script>
    function success(position) {
     

      var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
     
      var options = {
        zoom: 15,
        center: coords,
        mapTypeControl: false,
        navigationControlOptions: {
            style: google.maps.NavigationControlStyle.SMALL
        },
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("jomdirectoryFormSearchMaps"), options);

      var marker = new google.maps.Marker({
          position: coords,
          map: map,
          title:"You are here!"
      });
    }

    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(success);
    } else {
      error('Geo Location is not supported');
    }

    </script>

     

     

    To the end of mod_jomdirectory_maps/tmpl/default.php

     

    But the map reloads and I loose the directory markers.

     

    Must be because of line :

    var map = new google.maps.Map(document.getElementById("jomdirectoryFormSearchMaps"), options);

     

    Any idea on how I could get this done ?

     

    This would be a great feature for this map !!

     

    Best regards,

    David

×
×
  • Create New...