On Jul 30, 9:42 am, deanf7 <[email protected]> wrote:
> I use markClusterer and had the same problem you did. The markers
> would appear stacked on top of each other so only one was visible. If
> you're not too picky on having the exact lat and lng I did the
> following using PHP to slightly offset each marker from the first one
> found with that lat/lng. It creates a square of closely spaced
> markers.
Seems like a shortcoming of the markerclusterer. If the clustered
markers are all at the same location, it shouldn't "uncluster" them.
Perhaps someone should suggest that enhancement to the v3 open source
markerclusterer (or implement it...), although exactly what should
happen seems like it may depend on the user.
-- Larry
>
> <?php
> // set up arrays to check for duplicates
> $lat = array();
> $lng = array();
> $markers = array();
>
> while($row = $query->fetch(PDO::FETCH_OBJ)) {
> // Set arrays to last value to check for rows with same lat, lng,
> locDescription as previous row
> $prev_lat = end($lat);
> $prev_lng = end($lng);
> $prev_marker = end($markers);
>
> if(($row->lat == $prev_lat) && ($row->lng == $prev_lng)) {
> $random_num_lat = .00065 * mt_rand(1, 10);
> $random_num_lng = .00065 * mt_rand(1, 10);
> $newnode->setAttribute("lat", $row->lat + $random_num_lat);
> $newnode->setAttribute("lng", $row->lng + $random_num_lng);
> } else {
> $newnode->setAttribute("lat", $row->lat);
> $newnode->setAttribute("lng", $row->lng);
> }
>
> // add last marker values to arrays to check next marker for
> duplicates
> $lat[] = $row->lat;
> $lng[] = $row->lng;
> $markers[] = $row->locDescription;
>
> }
>
> Dean
>
> On Jul 28, 3:46 pm, Muj <[email protected]> wrote:
>
>
>
> > I am creating a google map with multiple markers. Some of the markers
> > have the same latitude and longitude. Is there any way to make sure
> > the marker shows up even if they are the same lat and long?
>
> > Here is the code:
>
> > <html>
> > <head>
> > <script type="text/javascript"
> > src="http://ajax.googleapis.com/ajax/
> > libs/jquery/1.4.2/jquery.min.js"></script>
> > <script type="text/javascript"
> > src="http://maps.google.com/maps/api/
> > js?sensor=false"></script>
> > <script type="text/javascript">
> > $(document).ready(
> > function(){
> > //alert("JS YO!");
> > var marker = [];
> > //var params = [];
> > $(".mapblock").each(function (i){
> > //alert( $(this).html());
> > marker[i] = [7];
> > params =
> > ($(this).html()).split("|");
> > //alert(params);
> > marker[i][0]= params[0];
> > marker[i][1] = params[1];
> > marker[i][2] = params[2];
> > marker[i][3]= params[3];
> > marker[i][4] = params[4];
> > marker[i][5]= params[5];
> > marker[i][6] = params[6];
> > marker[i][7]= params[7];
> > });
> > //alert(marker);
> > buildmap(marker);
> > }
> > );
> > //running the map function
> > function buildmap(spots){
> > //alert(spots.length);
> > var myOptions = {
> > zoom: 11,
> > center: new google.maps.LatLng(spots[0][0],
> > spots[0][1]),
> > //center: new google.maps.LatLng(-33.9,
> > 151.2),
> > mapTypeId: google.maps.MapTypeId.HYBRID
> > };
> > var map = new
> > google.maps.Map(document.getElementById("dealermap"),myOptions);
> > //var image = '<?=IMAGES?>main-elements/pin.png';
>
> > //alert(spots.length);
> > var markers = [];
> > for(var i=0; i < spots.length; i++){
> > //alert(spots[i]);
> > var dealer = spots[i];
> > //alert(dealer[0] + dealer[1]);
> > var dealerLatLong = new
> > google.maps.LatLng(dealer[0], dealer[1]);
> > var marker = new google.maps.Marker({
> > position: dealerLatLong,
> > map: map,
> > //icon: image,
> > zIndex: i
> > });
> > markers[i] = marker;
> > }
> > }
> > </script>
> > </head>
> > <body>
> > <div class="mapblock">36.91190|-76.21320|Bay Chevrolet Saab
> > Kia|6970
> > N. Military Hwy.|Norfolk|VA|23518|757-855-5555</div>
> > <div class="mapblock">36.88940|-76.23820|Enterprise|2630
> > Wyoming Ave|
> > Norfolk|VA|23513|757-855-6720</div>
> > <div class="mapblock">36.91190|-76.21320|Green Gifford|2747
> > N.
> > Millitary Hwy|Norfolk|VA|23518|757-284-3418</div>
> > <div class="mapblock">36.75220|-76.21680|Greenbrier
> > Chrysler Jeep|
> > 1414 South Military Highway|Chesapeake|VA|23320|888-559-6530</div>
> > <div class="mapblock">36.75220|-76.21680|Greenbrier Pontiac
> > GMC Kia|
> > 1300 S. Military Highway|Chesapeake|VA|23320|888-598-8968</div>
> > <div class="mapblock">36.75220|-76.21680|Greenbrier
> > Volkswagen|1248
> > S. Military Highway|Chesapeake|VA|23320|888-659-3562</div>
> > <div class="mapblock">36.75220|-76.21680|Greenbrier
> > Wholesale Center|
> > 1510 S. Military Highway|Chesapeake|VA|23320|888-876-4139</div>
> > <div class="mapblock">36.85650|-76.21180|Kimnach Ford|6401
> > E.
> > Virginia Beach Blvd.|Norfolk|VA|23502|757-461-6401</div>
> > <div class="mapblock">36.85650|-76.21180|Perry Buick
> > Pontiac Subaru|
> > 6633 Virginia Beach Blvd|Norfolk|VA|23502|757-461-8855</div>
> > <div class="mapblock">36.83760|-76.15100|Phillips Mercedes
> > Land
> > Rover|4949 Virginia Beach Blvd.|Virginia Beach|VA|23462|800-601-3644</
> > div>
>
> > <div id="dealermap"
> > style="width:770px;height:500px;border:1px solid
> > #ddd;"></div>
> > </body>
> > </html>- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.