I have div with coordinates attribute:
<div class="c" coordinates="32.100,-118.3232">
..
</div>
I’m getting coordinates with the help of jquery:
var coord = $(".c").attr("coordinates");
Do I need to convert this somehow when I need to put this into my google maps javascript:
var latlng = new google.maps.LatLng(coord );
addmarker(latlng)
function addmarker(latilongi) // function to add new marker when click on compare
{
var marker = new google.maps.Marker({
position: latilongi,
title: 'new marker',
draggable: true,
map: map
});
map.setCenter(marker.getPosition())
}
It seems like it doesn’t fall into the right place when it deploys onto my page,
Thanks
Provided that
var coord = $(".c").attr("coordinates")actually works, you’d have the same asvar coord = "32.100,-118.3232"That is a string, but the
google.maps.LatLng()object takes 2 numerical parameters. So,