javascript - Google Maps Error - Invalid latitude / longitude? -
i have following code:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <div class="row"> <div class="col-md-6" id="googlemap" style="height:500px;"></div> </div> <script> function initialize() { var mapprop = { center: new google.maps.latlng(44.6656, -83.5753), zoom: 10, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("googlemap") ,mapprop); var marker = new google.maps.marker({ position: mapprop, }); marker.setmap(map); } google.maps.event.adddomlistener(window, 'load', initialize); </script>
the map displays fine can't add marker. following error:
setposition: not latlng or latlngliteral: in property lat: not number
i don't see how latitude , longitude invalid because resulting generated map shows correct location. no marker.
the marker's position
property should of type latlng
:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <div class="row"> <div class="col-md-6" id="googlemap" style="height:500px;"></div> </div> <script> function initialize() { var cord = new google.maps.latlng(41.6656, -83.5753); var mapprop = { center: cord, zoom: 10, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("googlemap") ,mapprop); var marker = new google.maps.marker({ position: cord, }); marker.setmap(map); } google.maps.event.adddomlistener(window, 'load', initialize); </script>
Comments
Post a Comment