user1312312
user1312312

Reputation: 635

Migration from google maps V2 to Version 3

I am working on a migration project from google maps V2 to V3 and can't get the following working.

<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=myApiKey&sensor=false">
</script>

<script>
function initialize()
{
var map=new google.maps.Map(document.getElementById("googleMap"));
map.setCenter(new google.maps.LatLng(51.508742,-0.120850),5);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>

</body>
</html>

Actually I don't want to use the options parameter in the new google.maps.Map function. I want to center the map using map.center function.

Upvotes: 0

Views: 117

Answers (1)

duncan
duncan

Reputation: 31912

This is wrong:

map.setCenter(new google.maps.LatLng(51.508742,-0.120850),5);

setCenter only takes one parameter, the LatLng object. Try this:

map.setCenter(new google.maps.LatLng(51.508742,-0.120850));

Upvotes: 1

Related Questions