roryashfordbentley / Custom-Google-Maps

0 stars 0 forks source link

utilise GMaps JS API LatLng Class #1

Open DrizzlyOwl opened 8 years ago

DrizzlyOwl commented 8 years ago

Rather than defining your latlng as

latLong = {
    lat: parseFloat(mapElement.getAttribute('data-latitude')), 
    lng: parseFloat(mapElement.getAttribute('data-longitude'))
};

why not make use of GMaps LatLng Class instead?

latLong = new google.maps.LatLng(
    mapElement.getAttribute('data-latitude'),
    mapElement.getAttribute('data-longitude')
)

I believe google do certain checks and preps to ensure the latitude and longitude values are adhering to what their maps api is expecting to receive

https://developers.google.com/maps/documentation/javascript/reference?hl=en#LatLng

roryashfordbentley commented 8 years ago

I need to research more. Its my understanding that using the object method above returns an object literal so by using the object literal as I have it should be a little faster.

Have you got specifics on these checks that google.maps.LatLng performs?