gis - Google Maps fitBounds into specific area -


i want achieve following: "place array of markers may distributed across large range of lat, lng fitbounds method places fitbounds inside custom rectangle."

the image below should clarify i'm trying achieve. have array of markers want make sure fits within small box on right hand side of page.

the white box contains information pertaining markers, present, don't want markers hidden behind white box, , i'd love if define live within black box. (note black box visual reference question).

google maps bounds in box

you can use containslocation ensure point inside of polygon. see here.

as go through each coordinate pair in array, verify location within polygon area, add map accordingly. can set attribute points "define" extent in.

var latlng = new google.maps.latlng(array[n]); if (google.maps.geometry.poly.containslocation(latlng, polygon)){        marker = new google.maps.marker({          position: latlng,          map: map      });      marker.dataset.box = 'blackbox'; } else {        alert('not inside black box'); } 

if you're using html5, can add dataset attribute markers within polygon.

marker.dataset.box = 'blackbox'; 

if not, can use setattribute.

marker.setattribute('data-box', 'blackbox'); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -