Hi biswa- I would put all created markers in an array, and then remember the index of each marker in an array, and pass that into the function. Then you could say: map.removeOverlay(markers[ix]);
- pamela On Mon, Mar 16, 2009 at 7:55 PM, biswa rajgarh <[email protected]> wrote: > > Hi every one , > > How i have to delete a marker if i know the perticular point on which > marker is created. > Hewre is my code Please tell what to do in delMarker() function.As > marked. > > function getLocation() > { > var oSearchLocation = document.getElementById('gcLocation'); > > > if (oSearchLocation.value) > { > geocoder.reset(); > geocoder.getLocations > (oSearchLocation.value,addAddressToMap); > } > else > { > map.clearOverlays(); > alert("Type what you're looking for into the Search > box."); > } > } > > function addAddressToMap(response) > { > map.clearOverlays(); > if (!response || response.Status.code != 200) > { > loading = false; > switch (response.Status.code) > { > > default:alert(document.getElementById('gcLocation').value + > " is not found"); > } > } > > else > { > gResponse = response; > > var oMultiResultDiv = > document.getElementById > ('googleSearchData'); > oMultiResultDiv.innerHTML = ''; > var html = '<div class="titleDiv"></div>'; > > for (var n = 0 ; n < > response.Placemark.length ; n+ > + ) > { > if(n==0) > { > gotoPlacemark(n) //For First Marker > > } > html += createChoiceLink(n); > } > > > oMultiResultDiv.innerHTML = html; > > animatedcollapse.toggle('googleSearchData'); > animatedcollapse.show('googleSearchData'); > animatedcollapse.hide('searchOptions'); > > } > }; > > function delMarker(ix) > { > > SUGGESTED CODE------------------------------------ > > var pMark = gResponse.Placemark[ix]; > var point = new GLatLng(pMark.Point.coordinates > [1],pMark.Point.coordinates[0]); > > map.removeOverlay(pMark); > > } > > function createChoiceLink(ix) > { > var pMark = gResponse.Placemark[ix]; > var html = '<div class="aLink" onclick="gotoPlacemark > ('+ix+')">' + pMark.address + '<br/><a href="#" > onclick="javascript:delMarker('+ix+')">Delete</a><br/></div>'; > > return html; > } > > > function gotoPlacemark(ix) > { > var pMark = gResponse.Placemark[ix]; > var point = new GLatLng(pMark.Point.coordinates[1], > pMark.Point.coordinates[0]); > var html = ''; > html += '<b>Country code:</b> ' + > pMark.AddressDetails.Country.CountryNameCode + '<br>\n'; > html += '<b>Address:</b> ' + pMark.address + '<br>\n'; > > var marker = createMarker(point, pMark.address, html, 1, > null, true); > map.addOverlay(marker); > if(ix==0) > { > map.closeInfoWindow(); > marker.openInfoWindow(html); > } > > > > if (pMark.AddressDetails.Accuracy == 9) { > map.setZoom(15); > } > else if (pMark.AddressDetails.Accuracy >= 6) { > map.setZoom(15); > } > else if (pMark.AddressDetails.Accuracy >= 4) { > map.setZoom(12); > } > else if (pMark.AddressDetails.Accuracy >= 2) { > map.setZoom(7); > } > else { > map.setZoom(5); > } > map.panTo(point); > }; > > > function createMarker(point,markerName,markerHtml, > number,mIcon,mClickable,mapType) > { > mClickable = mClickable || false; > mapType = mapType || G_NORMAL_MAP; > > var latDMS = DEC2DMS(point.y); > var longDMS = DEC2DMS(point.x); > > var htmlInfo = ""; > htmlInfo += markerHtml; > > var htmlInfo2 = ""; > htmlInfo2 += 'Lat (Dec): ' + point.y + '<br>'; > htmlInfo2 += 'Long (Dec): ' + point.x; > htmlInfo2 += '<hr style="height:1px">'; > htmlInfo2 += 'Lat (DMS): ' + latDMS + '<br>'; > htmlInfo2 += 'Long (DMS): '+ longDMS; > htmlInfo2 += '</div>'; > > > > var marker = new GMarker(point,{icon:mIcon, > clickable:mClickable, title:markerName}); > > > > var gSmallIcon = new google.maps.Icon(); > gSmallIcon.image = "Common/Images/chart_11.png"; > gSmallIcon.shadow = "http://labs.google.com/ > ridefinder/images/mm_20_shadow.png"; > gSmallIcon.iconSize = new google.maps.Size(34, > 34); > gSmallIcon.shadowSize = new google.maps.Size(54, > 34); > gSmallIcon.iconAnchor = new google.maps.Point > (17, 34); > gSmallIcon.infoWindowAnchor = new > google.maps.Point(17,2.83); > > } > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API For Flash" 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-api-for-flash?hl=en -~----------~----~----~----~------~----~------~--~---
