Using Google Maps API for current location?

Discussion in 'Programming' started by mokimofiki, Nov 10, 2011.

  1. #1
    Heres the deal. I created a system that will find your current location and then pinpoint it on a google map within a website. This pinpoint works and shows up fine. Then it is supposed to find pinpoints around you based on a 5 mile radius from your current location. This does not work (it did a few days ago and just stopped). The following code are the functions to use Google's API to find your location and decide if it can or can't (this is where it seems to break but only after it finds your current location). Any thoughts would be great thank you.

    //FIND GEOLOCATION
    		if(navigator.geolocation) {
        browserSupportFlag = true;
        navigator.geolocation.getCurrentPosition(function(position) {
          initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
          map.setCenter(initialLocation);
    	  var infowindow = new google.maps.InfoWindow({
                  map: map,
                  position: initialLocation,
                  content: 'You are here.'
    			});
    	  		searchLocationsNear(initialLocation);
                map.setCenter(initialLocation);
    	  
        }, function() {
          handleNoGeolocation(browserSupportFlag);
        });
    	// Browser doesn't support Geolocation
      } else {
        browserSupportFlag = false;
        handleNoGeolocation(browserSupportFlag);
      }
    	//END FIND GEOLOCATION
    
    
    function handleNoGeolocation(errorFlag) {
            if (errorFlag) {
            map = new google.maps.Map(document.getElementById("map"), {
            center: new google.maps.LatLng(40, -100),
            zoom: 4,
            mapTypeId: 'roadmap',
            mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
          });
            }
    
            var options = {
              map: map,
              position: new google.maps.LatLng(60, 105),
              content: content
            };
    
            var infowindow = new google.maps.InfoWindow(options);
            map.setCenter(options.position);
          }
    
    //
          infoWindow = new google.maps.InfoWindow();
    
          locationSelect = document.getElementById("locationSelect");
          locationSelect.onchange = function() {
            var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
            if (markerNum != "none"){
              google.maps.event.trigger(markers[markerNum], 'click');
            }
          };
    		  //
            }
    Code (markup):

     
    mokimofiki, Nov 10, 2011 IP
  2. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Problem solved ... it looks like its an issue with a different function that this part returns a false on. Therefore if anyone is looking at this for reference its all correct here.
     
    mokimofiki, Nov 10, 2011 IP