मैं जो हासिल करना चाहता हूं (और अब तक कुछ भी नहीं मिला) वह यह है कि जानकारीविंडो मार्कर से जुड़ी नहीं है। मैं इसे अपने व्यूपोर्ट में एक स्थिर स्थिति पर रखना चाहता हूं और केवल सामग्री का आदान-प्रदान करना चाहता हूं कि किस मार्कर पर क्लिक किया गया है।
प्रश्न: मैं एक निश्चित स्थान पर एक गूगल मैप्स मार्कर इन्फोविंडो कैसे रख सकता हूं (और सिर्फ ऑफसेट नहीं)।
4
kaiser
31 अगस्त 2011, 01:21
1 उत्तर
सबसे बढ़िया उत्तर
मेरे अपने प्रश्न का उत्तर देना - यदि किसी को इसकी आवश्यकता हो:
// Add somewhere before creating your map to hide the info window as long as it got no content:
<script type="text/javascript">
jQuery( '#info' ).hide();
</script>
<script type="text/javascript">
function createMarker( lat, lng, whatever ) {
// map_object_name = the name of your map when you init()
html = "<strong>" + whatever + "</strong>";
var marker = new google.maps.Marker( {
map: map_object_name,
position: new google.maps.LatLng( lat, lng )
} );
// This snippet adds the content on the fly (when you click the marker)
google.maps.event.addListener( marker, 'click', function() {
// This pans the viewport/centers the marker in your viewport
map_object_name.panTo( new google.maps.LatLng( lat, lng ) );
// This shows the html-element with the id "info" and adds the html content
jQuery( '#info' ).show();
// This clears the content before you add new one
jQuery( '#info' ).empty();
jQuery( '#info' ).append( html );
// Commented out - just as reference
// infoWindow.setContent( html ); // the original infoWindow as you know it from Google Maps
// infoWindow.open( map_object_name, marker ); // the same, just the callback
} );
}
</script>
#info
तत्व की "प्लेसिंग"/पोजिशनिंग सामान्य एचटीएमएल और सीएसएस के साथ की जा सकती है।
6
kaiser
31 अगस्त 2011, 12:19
#info
DOM तत्व मानचित्र के बाहर है, लेकिन टिप्पणी की गईinfoWindow
मानचित्र पर होनी चाहिए - आप अभी भी इसे बनाना होगा। हम्म। आप बस#map
कंटेनर कोposition: relative; z-index: 1;
और#info
तत्व कोposition: absolute; top: XYpx; left/right: XYpx; z-index: 10;
पर सेट कर सकते हैं ताकि इसे मानचित्र के ऊपर एक स्थिर स्थिति में लाया जा सके।