Jump to content

GeoLocate visitor in Ajax map

Recommended Posts



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


I checked this tutorial :



I managed to GeoLocate the user, by adding :


<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></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) {
} else {
  error('Geo Location is not supported');




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,


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now