I'm trying to learn the Google Maps and Places API, so I thought I'd get started with the basics: displaying the user's location on a map via their IP address.
I found a jQuery script in another thread which gets the user's latitude and longitude and it works fine (an alert placed below the var displays the latitude and longitude), but when I pass the variable to the Maps method, it doesn't work. Can someone see anything wrong with my function or how it's being called?
$.getJSON('http://api.wipmania.com/jsonp?callback=?', function (data) {
var latlng = new google.maps.LatLng(data.latitude,data.longitude);
function initialize() {
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
});
EDIT: By the way, these are the scripts that I'm using:
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script language="javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>