Gmap3 - Forum

Gmap3 exchange platform

You are not logged in.

Ads
(server costs 27.50€ per month)


#1 2012-10-13 11:20:25

tyger86
Member
Registered: 2012-10-13
Posts: 1

Confused and hairless please help

Hello everyone,

I am working on a store locator at http://czcigars.com/cisite/retailers/locator but am stuck on a fairly early stage. Right now I am just trying to get the enter your location box to update the map. Which I did however the refresh map button needs to be double clicked before it works. I can't for the life of me figure out why and would be most great full for any insights anyone has to offer.

Hear is my javascript

$(document).ready( function() {
	clear_map();
	update_map();
	
	$('#refresh').click( update_map );
})

function get_user_location() {
	return { lat: $('#from').attr('lat'), lng: $('#from').attr('lng') }
}

//Get lat and lng from address
function update_user_location() {
	var address = $('#from').val();
	var mygc = new google.maps.Geocoder();
	mygc.geocode({'address' : address }, function(results, status){
			$('#from').attr('lat', results[0].geometry.location.lat());
			$('#from').attr('lng', results[0].geometry.location.lng());
	});
}

function update_map() {
	update_user_location();
	clear_map();
	draw_map();
}

function draw_map() {
	$('#map').gmap3(
		{
			action: 'addMarker',
			latLng: get_user_location(),
			map:{
			center: true,
			zoom: 5,
			mapTypeId: google.maps.MapTypeId.TERRAIN
			}
		}
	);
}

function clear_map() {
	$('#map').gmap3({ action: 'clear' });
}

Offline

Ads
(server costs 27.50€ per month)


Board footer

Powered by FluxBB