moshen / node-googlemaps

A simple way to query the Google Maps API from Node.js
MIT License
559 stars 148 forks source link

Is there a way to calculate center for multiple points. #143

Closed jitendra-kr closed 6 years ago

jitendra-kr commented 7 years ago

Hi,

I am working on car tracking application in nodeJs.

  1. I have 100 to 100000 coordinates for a trip. After drawing path on map. Now i need to set a valid center of map. I am stuck here.
  2. How can i pass lat, long instead of address

    markers: [ { location: 'C-20/1, Sector-62, Noida, Uttar Pradesh 201301', label : 'S', color : 'green', shadow : true,

    }

is there a way use only lat, long instead of (C-20/1, Sector-62, Noida, Uttar Pradesh 201301).

Liamdelee commented 6 years ago

Lat Long can be passed like '51.06199,4.362622' note the '. for the center if you use static map just remove the center and zoom tags and google will auto search for the best center and zoom for your call. documented here

example:
var params = {
  size: '640x640',
  maptype: 'roadmap',
  markers: [
    {
      location: LatLong1,
      label   : '1',
      color   : 'green',
      shadow  : true
    },
    {
      location: LatLong2,
      label   : '2',
      color   : 'blue',
      shadow  : true
    },
    {
      location: LatLong3,
      label   : '3',
      color   : 'red',
      shadow  : true
    }
  ],
  style: [
    {
      feature: 'road',
      element: 'all',
      rules: {
        hue: '0x00ff00'
      }
    }
  ]
};
jitendra-kr commented 6 years ago

Thanks Liamdelee