Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

setCenter: not a LatLng or LatLngLiteral with finite coordinates: in property lat: not a number

70

The .value attribute of a HTMLInputElement returns the value as a string.

You have to parse the content of lat and lng with parseFloat() before passing it to the maps API

function initAutocomplete() {
    var lat = parseFloat(document.getElementById('lat').value);
    var lng = parseFloat(document.getElementById('lng').value);

    var map = new google.maps.Map(document.getElementById('map'), {
        center: {
            lat: lat,
            lng: lng
        },
        zoom: 13,
        mapTypeId: 'roadmap'
    });
}
Comment

setCenter: not a LatLng or LatLngLiteral with finite coordinates: in property lat: not a number

//The error comes because you pass the value as string:
var lat = document.getElementById('lat').value;

//you need to set it as float:
var lat = parseFloat(document.getElementById('lat').value);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery get all data attributes values 
Javascript :: jest express testing 
Javascript :: append string javascript 
Javascript :: iterate over array javascript 
Javascript :: jquery replace multiple words 
Javascript :: input set variable angular 
Javascript :: npm paypal express checkout 
Javascript :: mong db connect error 
Javascript :: add word in string in javascript 
Javascript :: bind jquery 
Javascript :: how to target html elements in javascript 
Javascript :: get index of first number in string javascript 
Javascript :: javascript trim text 
Javascript :: get index of selector jquery 
Javascript :: how to check characters inside a string javascript 
Javascript :: wheel 
Javascript :: add object in array state react 
Javascript :: angular date pipi locale 
Javascript :: address 
Javascript :: next js get gurrent page params 
Javascript :: javascript pop object from array 
Javascript :: how to use javascript to hide content and show through link 
Javascript :: how i do button when click open a new tab in react 
Javascript :: Example Of LinkedList In JavaScript 
Javascript :: javascript prevent value change in select option 
Javascript :: drag drop in blazor 
Javascript :: groubbykey js 
Javascript :: spray scala JSON formatter override def read examples 
Javascript :: can we fine a key with help of value in array of objects javascript 
Javascript :: how to find the radius of a loacation in node js 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =