0

i've placed around 3 hundreds of markers on google map and i also need to highlight some regions with Cirlce on it. So i've placed 3 circles on the map. I wanna show markers only inside circle, not outside the circles. Circles can be placed any where(say fixed radius) and markers shoud be inside circles. all marking and placing circles are in javascript. I'm fresh grad and new to javascript.

Pradi

The part where i draw circle.

       for (var i = 0; i < ltlg.length; i++) {

    var marker = new google.maps.Marker({
        map: map,
        position: ltlg[i],
        visible: false
    });

    var circle = new google.maps.Circle({

        map: map,
        radius: 10 * 55000,
        fillcolour: '#AA0000'

    });

    circle.bindTo('center', marker, 'position');
}

where ltlg[i] is array containg 3 lats and longs.

and part where i mark

for (var i = 0; i < ltlg1.length; i++) {

        // var detail = cityDetails[i];
        var markerSnowFall = new google.maps.Marker({
            map: map,
            icon: Image,
            position: ltlg1[i]

        });

Here ltlg1[i] contains some 300 hundred lats and longs.

Problem is that i dont know how to make connection between marking and placing circles, currently both(marking use ltlg1[i] and cicle use ltlg[i]) use different arrays.

Pradi
  • 1
  • 1
  • Please post some code so we can see what effort you've made to solve this yourself and know where to start assisting you. – sirmdawg May 16 '12 at 06:28
  • Thanks for replying mkprogramming. I've posted code. Please if you know anything on this, then let me know. – Pradi May 16 '12 at 07:39

1 Answers1

0

Either make a loop that for each of the markers checks if the distance to the center of the circle means that the marker is within the circle and only show the markers that fits this

or if the way you are placing the markers on a map supports it, only send markers that should be drawn (for instance in a previous project we had the position of the markers in a db that we could query for all markers within a circle)

Jontas
  • 409
  • 3
  • 12
  • Thanks for replying Jontas, The second part where yur saying to query db is not possible. becasuse i ain't connected to db. All lats and longs which i've marked are in array and there is loop where i place marker on each element of that array. The first part of calculating the distance seems to be a good approach but can u elaborate bit with an example or so – Pradi May 16 '12 at 07:15
  • Check out for instance http://www.movable-type.co.uk/scripts/latlong.html or http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points – Jontas May 16 '12 at 11:39
  • Okay. Thank You, I'll check those links. – Pradi May 17 '12 at 10:59