Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HERE api - get map center

I'm new with HERE API (still testing it) I have 2 questions:

  1. I have number of pins on the map. Can you script find automatically the center of the pins locations

  2. For each pin I have div box with info (each div have unique ID). can I click on the pin and the page will scroll to the right div/position? see example here with google map: http://www.followmyroutes.com/index.php?page=itinPage&itinID=16

Regards,

Roi

like image 571
Roi Avatar asked Aug 16 '26 01:08

Roi


1 Answers

Zooming to a set of markers is easy. The idea is to use the method setViewBounds on the map instance.

// some examples marker
var toronto = new H.map.Marker({lat:43.7,  lng: -79.4});
var boston = new H.map.Marker({lat:42.35805, lng: -71.0636}),
var washington = new H.map.Marker({lat:38.8951, lng: -77.0366}),

// a group object to contain the markers
var group = new H.map.Group();

// add markers to the group
group.addObjects([toronto, boston, washington]);

// add the group to the map instance
map.addObject(group);

// get geo bounding box for the group and zoom into it
map.setViewBounds(group.getBounds());
like image 57
Michael P. Bazos Avatar answered Aug 18 '26 14:08

Michael P. Bazos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!