2012-12-19 52 views
10

Google मानचित्र V3 में, बहुभुज के अंदर और ऊपर लेबल कैसे डालें? वी 2 में कोई लेबल ओवरले नहीं है जब मैं लाइब्रेरी मैपल लेबल का उपयोग करता हूं, तो मैं टेक्स्ट को अंदर रख सकता हूं, लेकिन ऊपर नहीं, भले ही मैं उच्च जेड-इंडेक्स निर्दिष्ट करता हूं। धन्यवाद फिलGoogle मानचित्र V3 में, बहुभुज के अंदर और ऊपर लेबल कैसे डालें?

+1

क्या आपने कभी इसे समझ लिया था? –

+2

क्या आप [this] (http://www.geocodezip.com/geoxml3_test/v3_FusionTables_zipcode_map_whiteBg.html) जैसे कुछ ढूंढ रहे हैं (बहुभुज के लिए फ़्यूज़नटेबल्सलेयर का उपयोग करता है, लेबल के लिए इन्फोबॉक्स) – geocodezip

+0

[Google मानचित्र जावास्क्रिप्ट एपीआई v3 मानचित्र का संभावित डुप्लिकेट लेबल और बहुभुज] (http://stackoverflow.com/questions/12714031/google-maps-javascript-api-v3-map-label-and-polygons) – geocodezip

उत्तर

0

उपयोग google-maps-utility-library

सेट लेबल सामग्री, अपने बहुभुज के center position खोजने के लिए और thats यह :)

var labelOptions = { 
    content: label, 
    boxStyle: { 
     textAlign: "center", 
     fontSize: "8pt", 
     width: "50px" 
    }, 
    disableAutoPan: true, 
    pixelOffset: new google.maps.Size(-25, 0), 
    position: this.my_getBounds(gpoints).getCenter(), 
    closeBoxURL: "", 
    isHidden: false, 
    pane: "mapPane", 
    enableEventPropagation: true 
}; 

var polygonLabel = new InfoBox(labelOptions); 
polygonLabel.open(map); 
-1

maplabel mapPane, जो आम तौर पर नीचे renders में एक कैनवास पर अपने पाठ renders फ्लोटपेन में सभी zIndex मान। अपने zindex क्रम में mapPane कैनवास लाने के लिए, कोशिश:

var mapLabel = new MapLabel({ 
    position: new google.maps.LatLng(yourLat, yourLng), 
    text: 'test', 
    zIndex: 101}); 
$(mapLabel.getPanes().mapPane).css('z-index', mapLabel.zIndex); 
1

यह बहुत देर हो चुकी है, लेकिन मैं एक ही समस्या का सामना करना पड़ा है और इस कोड ठीक काम करता है!

var triangleCoords = [ 
    { lat:30.655993, lng: 76.732375 }, 
    { lat: 30.651379, lng: 76.735808}, 
    { lat: 30.653456, lng: 76.729682} 
] 

var bermudaTriangle = new google.maps.Polygon({ 
    paths: triangleCoords , 
    strokeColor: '#FF0000', 
    strokeOpacity: 0.8, 
    strokeWeight: 2, 
    fillColor: '#FF0000', 
    fillOpacity: 0.35 
}); 
attachPolygonInfoWindow(bermudaTriangle) 

function attachPolygonInfoWindow(polygon) { 
    var infoWindow = new google.maps.InfoWindow(); 
    google.maps.event.addListener(polygon, 'mouseover', function (e) { 
     infoWindow.setContent("Polygon Name"); 
     var latLng = e.latLng; 
     infoWindow.setPosition(latLng); 
     infoWindow.open(map); 
    }); 
} 
+0

ठीक काम करता है! बहुत बहुत धन्यवाद। –