When I using this code
<li latlon="58.55801847109299,11.244826413745159" class="point_on_map">Boviken, Hamburgö</li>
And this jQuery code:
$('.point_on_map').click(function(){
var b = new google.maps.LatLng($(this).attr('latlon'));
map.setCenter(b);
});
And when I click the center is in the blue, and the marker is in the left upper corner, and not draggable…
What have is wrong?
What you’re actually doing there is passing one string to
LatLngwhen you need to be passing it two. That comma in thelatlonattribute doesn’t get interpretted by JavaScript how you’re thinking it does, it just gets seen as part of the string.You need to split your
58.55801847109299,11.244826413745159into two variables (e.g.58.55801847109299and11.244826413745159) and pass them separately toLatLng. e.g.That’s untested code but hopefully you get the idea.