2016-10-27 21 views
8

द्वारा Google मानचित्र पर ग्रिड लाइनों को निकालें, Google मानचित्र से सफेद ग्रिड लाइन को कैसे निकालें? मैंने ज़ूम जोड़ा है: 0.7 सीएसएस संपत्ति div और मेरे शोध से मैप करने के लिए, ये गुण सफेद रेखाएं जोड़ रहे हैं।ज़ूम

क्या ज़ूम संपत्ति को हटाए बिना Google मानचित्र से सफेद रेखा को निकालना संभव है? जैसा कि मुझे मानचित्र की बिल्कुल आवश्यकता है जैसा कि अभी है। या हमारे पास ज़ूम करने का विकल्प है?

यहाँ कोड है:

function initMap() { 
 
    var map = new google.maps.Map(document.getElementById('map'), { 
 
    zoom: 5, 
 
    disableDefaultUI: true, 
 
    center: { 
 
     lat: 38.755724, 
 
     lng: -96.492369 
 
    } 
 
    }); 
 

 
}
html, 
 
body { 
 
    height: 100%; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
#map { 
 
    height: 100%; 
 
    zoom: 0.7; 
 
    -moz-transform: scale(0.8); 
 
    -moz-transform-origin: 0 0; 
 
}
<div id="map"></div> 
 
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script>

यहाँ यह कैसे दिखता है:

Google Maps with grid lines

+0

उन मानचित्र टाइल की सीमाओं कर रहे हैं। – geocodezip

+0

क्या उनसे छुटकारा पाने का कोई तरीका है? – dang

+0

आप ज़ूम का उपयोग क्यों करेंगे। यह माउस घटनाओं को भी खराब करता है। –

उत्तर

2

इसका कारण यह है कि आप नक्शे स्केलिंग रहे हैं। एक ट्रांसफॉर्म-शैली जोड़ने का प्रयास करें: संरक्षित-3 डी; और फिर जेड अक्ष पर स्केल करने के लिए आइटम का अनुवाद करें।

आप ऐसा करते हैं:

transform-style:preserve-3d; 
transform:perspective(500px) translateZ(-30vw) scale(1.4); 
perspective:1000; 

आप यूपी स्केलिंग रहे हैं, जो इस मुद्दे को दरकिनार कर देना चाहिए। अजीब चीजें तब होती हैं जब आप अन्य स्केल किए गए आइटम नीचे वाले आइटम स्केल करते हैं।

अनुवादेट (-30vw) कह रहा है, व्यूपोर्ट चौड़ाई का 30%। मेरे पास कुछ बीयर हैं, लेकिन मुझे लगता है कि यह 0.7 ज़ूम जैसा ही हो सकता है, जिसे आइटम चौड़ाई (100% व्यूपोर्ट चौड़ाई) से गणना की जाती है।

तब तब तक स्केल के साथ खेलें जब तक आप सिंथेटिक ज़ूम स्तर पर न हों।

+0

इसके लिए धन्यवाद। मैंने इसे यहां कार्यान्वित किया - http://ec2-54-198-148-171.compute-1.amazonaws.com/webapp/problem.html। हालांकि, मुझे लगता है कि पूर्ण स्क्रीन चली गई है। मुझे नक्शा केंद्रित के साथ मानचित्र पूर्ण स्क्रीन की जरूरत है। मैं उसे कैसे कर सकता हूँ? – dang

+0

पूर्ण स्क्रीन कैसे करें इस पर कोई तरीका है? – dang

+0

अब आप अपने स्केल वैरिएबल को बढ़ाना चाहते हैं कि आपने इसे वापस z-space –

1

नोट: परिवर्तन (500px) को (ऑटो)

बदलें इस शैली - केंद्रित नक्शे के साथ पूर्ण स्क्रीन के लिए।

सीएसएस

html, body { 
    height: 100%; 
    margin: 0; 
    padding: 0; 
} 

#map { 
    height: 100%; 
    transform-style:preserve-3d; 
    transform:perspective(auto) translateZ(-30vw) scale(1.4); 
    perspective:1000;  
} 

डेमो

Google Map - full screen

+0

यदि मैं परिप्रेक्ष्य (ऑटो) का उपयोग करता हूं, translateZ और स्केल अप्रभावी हो जाता है। उन मूल्यों को बदलने के बाद भी, यह काम नहीं करता है। – dang

+0

अनुवाद जेड बनाने और उपयोग करने योग्य स्केल करने के लिए कोई विचार? – dang

-1

इस चेक, यह आप

<!DOCTYPE html> 
<html> 
    <head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="utf-8"> 
    <title>Showing/Hiding overlays</title> 
    <style> 
     /* Always set the map height explicitly to define the size of the div 
     * element that contains the map. */ 
     #map { 
     height: 100%; 
     } 
     /* Optional: Makes the sample page fill the window. */ 
     html, body { 
     height: 100%; 
     margin: 0; 
     padding: 0; 
     } 
     #floating-panel { 
     position: absolute; 
     top: 10px; 
     left: 25%; 
     z-index: 5; 
     background-color: #fff; 
     padding: 5px; 
     border: 1px solid #999; 
     text-align: center; 
     font-family: 'Roboto','sans-serif'; 
     line-height: 30px; 
     padding-left: 10px; 
     } 
    </style> 
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script> 
    <script> 
     // This example adds hide() and show() methods to a custom overlay's prototype. 
     // These methods toggle the visibility of the container <div>. 
     // Additionally, we add a toggleDOM() method, which attaches or detaches the 
     // overlay to or from the map. 

     var overlay; 

     USGSOverlay.prototype = new google.maps.OverlayView(); 

     function initMap() { 
     var map = new google.maps.Map(document.getElementById('map'), { 
      zoom: 11, 
      center: {lat: 62.323907, lng: -150.109291}, 
      mapTypeId: 'satellite' 
     }); 

     var bounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(62.281819, -150.287132), 
      new google.maps.LatLng(62.400471, -150.005608)); 

     // The photograph is courtesy of the U.S. Geological Survey. 
     var srcImage = 'https://developers.google.com/maps/documentation/javascript/'; 
     srcImage += 'examples/full/images/talkeetna.png'; 

     overlay = new USGSOverlay(bounds, srcImage, map); 
     } 

     /** @constructor */ 
     function USGSOverlay(bounds, image, map) { 

     // Now initialize all properties. 
     this.bounds_ = bounds; 
     this.image_ = image; 
     this.map_ = map; 

     // Define a property to hold the image's div. We'll 
     // actually create this div upon receipt of the onAdd() 
     // method so we'll leave it null for now. 
     this.div_ = null; 

     // Explicitly call setMap on this overlay 
     this.setMap(map); 
     } 

     /** 
     * onAdd is called when the map's panes are ready and the overlay has been 
     * added to the map. 
     */ 
     USGSOverlay.prototype.onAdd = function() { 

     var div = document.createElement('div'); 
     div.style.border = 'none'; 
     div.style.borderWidth = '0px'; 
     div.style.position = 'absolute'; 

     // Create the img element and attach it to the div. 
     var img = document.createElement('img'); 
     img.src = this.image_; 
     img.style.width = '100%'; 
     img.style.height = '100%'; 
     div.appendChild(img); 

     this.div_ = div; 

     // Add the element to the "overlayImage" pane. 
     var panes = this.getPanes(); 
     panes.overlayImage.appendChild(this.div_); 
     }; 

     USGSOverlay.prototype.draw = function() { 

     // We use the south-west and north-east 
     // coordinates of the overlay to peg it to the correct position and size. 
     // To do this, we need to retrieve the projection from the overlay. 
     var overlayProjection = this.getProjection(); 

     // Retrieve the south-west and north-east coordinates of this overlay 
     // in LatLngs and convert them to pixel coordinates. 
     // We'll use these coordinates to resize the div. 
     var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest()); 
     var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast()); 

     // Resize the image's div to fit the indicated dimensions. 
     var div = this.div_; 
     div.style.left = sw.x + 'px'; 
     div.style.top = ne.y + 'px'; 
     div.style.width = (ne.x - sw.x) + 'px'; 
     div.style.height = (sw.y - ne.y) + 'px'; 
     }; 

     USGSOverlay.prototype.onRemove = function() { 
     this.div_.parentNode.removeChild(this.div_); 
     }; 

     // Set the visibility to 'hidden' or 'visible'. 
     USGSOverlay.prototype.hide = function() { 
     if (this.div_) { 
      // The visibility property must be a string enclosed in quotes. 
      this.div_.style.visibility = 'hidden'; 
     } 
     }; 

     USGSOverlay.prototype.show = function() { 
     if (this.div_) { 
      this.div_.style.visibility = 'visible'; 
     } 
     }; 

     USGSOverlay.prototype.toggle = function() { 
     if (this.div_) { 
      if (this.div_.style.visibility === 'hidden') { 
      this.show(); 
      } else { 
      this.hide(); 
      } 
     } 
     }; 

     // Detach the map from the DOM via toggleDOM(). 
     // Note that if we later reattach the map, it will be visible again, 
     // because the containing <div> is recreated in the overlay's onAdd() method. 
     USGSOverlay.prototype.toggleDOM = function() { 
     if (this.getMap()) { 
      // Note: setMap(null) calls OverlayView.onRemove() 
      this.setMap(null); 
     } else { 
      this.setMap(this.map_); 
     } 
     }; 

     google.maps.event.addDomListener(window, 'load', initMap); 
    </script> 
    </head> 
    <body> 
<!-- Add an input button to initiate the toggle method on the overlay. --> 
    <div id="floating-panel"> 
     <input type="button" value="Toggle visibility" onclick="overlay.toggle();"></input> 
     <input type="button" value="Toggle DOM attachment" onclick="overlay.toggleDOM();"></input> 
    </div> 
    <div id="map"></div> 
    </body> 
</html> 
+0

क्या आपने वास्तव में https://developers.google.com/maps/documentation/javascript/examples/overlay-hideshow से _completely unrelated_ उदाहरण को कॉपी-पेस्ट किया था? – tmslnz

0

मदद मिल सकती है कि आप कुछ समय की बचत की आशा में, मैं नहीं मानता कि जो आप प्राप्त करने की कोशिश कर रहे हैं वह सीएसएस ट्रांसफॉर्म हैक्स याके माध्यम से संभव है(नहीं-नहीं)। आप मंच-विशिष्ट हार्डवेयर प्रतिपादन, Google के मानचित्र प्रतिपादन इंजन, ब्राउज़र कार्यान्वयन विविधता इत्यादि के साथ हेड-ऑन लड़ रहे हैं और आपके पास जो कुछ भी है, वह उन तीन दिग्गजों के आसपास काम करने के लिए सीएसएस नियमों का एक मुट्ठी भर है।

संक्षेप में और उदाहरण के लिए: यहां तक ​​कि यदि आपको मैक पर क्रोम में ठीक काम करने के लिए मिला है, तो विंडोज़ पर फ़ायरफ़ॉक्स अभी भी टाइल सीमाएं या अन्य कलाकृतियों को दिखा सकता है।

अधिक रचनात्मक, आप Leaflet.js जो आप अपने नक्शे पर एक बहुत अधिक विकल्प और नियंत्रण देगा कोशिश करते हैं और आप टाइल्स का समर्थन करने वाले गैर पूर्णांक ज़ूम स्तर का उपयोग की अनुमति देना चाहेंगे।

+0

मैक पर क्रोम पर काम करना ठीक है क्योंकि मुझे आईपैड वेब व्यू पर एम्बेड करने की आवश्यकता है। अच्छा होने पर पत्रक, लेकिन इसका उपयोग नहीं कर सकता, क्योंकि मुझे Google मानचित्र की आवश्यकता है। – dang

+0

तब मुझे डर है कि आप भाग्य से बाहर हो सकते हैं, जब तक कि आप अपनी कुछ बाधाओं को आराम न करें। – tmslnz

0

उस खाली रेखा से बचने का सबसे अच्छा तरीका समेकित ज़ूम में एक पूर्णांक मान को मजबूर कर रहा है। सीएसएस में zoom: 0.7 के प्रभाव की नकल करने के लिए मानचित्र आमंत्रण से zoom :5zoom: 4 हो सकता है।

यदि आपको गणना के अनुसार वह संख्या मिलती है, तो उसे Math.round में डालने का ध्यान रखें।

वास्तव में, zoom: 4 मानचित्र की समान सटीक उपस्थिति नहीं है, लेकिन आप उस संपत्ति में फ़्लोट फ़ील्ड का उपयोग नहीं कर सकते हैं। यदि आप रिक्त रेखाओं को हटाना चाहते हैं, तो Google मानचित्र की zoom संपत्ति के माध्यम से मानचित्र ज़ूम प्राप्त करने के लिए बेहतर है, क्योंकि सीएसएस zoom एक बहिष्कृत, पुरानी शैली वाली आईई संपत्ति है जिसे टालना चाहिए।

https://css-tricks.com/almanac/properties/z/zoom/

https://developers.google.com/maps/documentation/static-maps/intro#Zoomlevels

इसके अलावा, नक्शे के केंद्र MapView के केंद्र में है।

function initMap() { 
 
    var map = new google.maps.Map(document.getElementById('map'), { 
 
    zoom: 4, 
 
    disableDefaultUI: true, 
 
    center: { 
 
     lat: 38.755724, 
 
     lng: -96.492369 
 
    } 
 
    }); 
 

 
}
html, 
 
body { 
 
    height: 100%; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
#map { 
 
    height: 100%; 
 
    -moz-transform: scale(0.8); 
 
    -moz-transform-origin: 0 0; 
 
}
<div id="map"></div> 
 
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script>

संबंधित मुद्दे