Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MadLittleMods/093c545f9900a29f2fc7 to your computer and use it in GitHub Desktop.

Select an option

Save MadLittleMods/093c545f9900a29f2fc7 to your computer and use it in GitHub Desktop.

Using the Google maps JS API. When calling InfoWindow.open(map, marker); you may come across the following error:

Uncaught TypeError: a.lat is not a function

This is caused by setting the position property in the map options object.

var myLatLng = {
	lat: 41.771312,
	lng: -48.427734
};

var myMap = new mapsApi.Map({
	// This will cause the error
	position: myLatLng
});

var marker = new google.maps.Marker({
	position: myLatLng,
	map: map,
	title: 'Some Marker'
});

var infoWindow = new mapsApi.InfoWindow({
	content: 'foo'
});
infoWindow.open(map, myMarker);

I have no idea why this is an issue but I bashed my head into this and it was really annoying to figure out what went wrong. Luckily version control ftw to narrow down what changes caused this.

@AlkarE
Copy link
Copy Markdown

AlkarE commented Jan 10, 2017

I'm facing with the same issue, but thank you for your explanation. I just commented this line.
And, I think that position argument isn't need in this case, I used center argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment