Search code examples
javascriptmapsmapquest

mapquest pointing to center the map for a POI in Javascript API


I am using mapquest for adding new locations with following code from Javascript API.

  window.map = new MQA.TileMap(       /*constructs an instance of MQA.TileMap*/
    document.getElementById('map'),   /*ID of element on the page where you want the map added*/
    7,                                /*intial zoom level of the map*/
    {lat:17.73, lng:83.3}, /*center of map in latitude/longitude */
    'map');                           /*map type (map)*/

    var poi=new MQA.Poi({lat:data.lat, lng:data.lng});
    map.addShape(poi);

Now, what I want is, the map should be center to the newly added POI instead of the default one. I think there might be some API for this, but so far I could not trace it out. Please help me.


Solution

  • You should use

    map.setCenter({lat:data.lat, lng:data.lng});
    

    It will work.