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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...