Jump to content

load google map api3 over click ajax call


Petani

Recommended Posts

hi guys, im new with google map, i need some help.

i have ajax call, here:

$('#checkbtn').click(function(e)
{
       e.preventDefault();
	var lo=$("#long").val();
	var la=$('#lat').val();
	$.ajax({
		url:BASEURL+'register/checklocation',
		type:'POST',
		data:{log:lo,lat:la},
		success:function(data)
		{	
			$('#view_checkmap').html(data);
		}
	});
});

here is my view to view the map:

<script>
function initialize()
{
  		var myLatlng = new google.maps.LatLng(<?php echo $lat; ?>,<?php echo $long; ?>);
  		var mapOptions = {
    		zoom: 15,
		    center: myLatlng,
		    mapTypeId: google.maps.MapTypeId.ROADMAP
 		}
 		var map = new google.maps.Map(document.getElementById('mymap'), mapOptions);
		var marker = new google.maps.Marker({
      		position: myLatlng,
      		map: map,
      		title: 'my location'
  		});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="mymap" style="width:500px; height:300px;"></div>

when i access to the URL, it displays, but when i access over ajax, nothing display.
is my code worng or something else?
thanks in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.