title: Messed up polygons shape when combining google map with Spatial Polygons
body: <p>I´m having problems when combining a map from Google Map Api, with a map constructed with <code>geom_polygon</code> from <code>ggplot2</code>. When I plot each map on their own, nothing weird shows up, but when I do combine them, some lines(straight) appear, messing up the boundaries I intend to highlight.</p>
  
  <p><a href="https://i.stack.imgur.com/UYiZv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UYiZv.png" alt="enter image description here"></a></p>
  
  <p>1) The data I´m using to construct the polygos with the black borders comes from this <a href="http://www.censo2017.cl/wp-content/uploads/2016/12/R05.zip" rel="nofollow noreferrer">link</a>. The exact url of the file is in my code below. Sometimes it is necessary to unzip the file manually, therefore the code below for downloading the data may not work:</p>
  
  <pre><code>path &lt;- getwd()
  fileName &lt;- "R05.zip"
  if (!file.exists(fileName)) {
      urlFile = "http://www.censo2017.cl/wp-content/uploads/2016/12/R05.zip" 
              download(urlFile, dest = "./R05.zip", mode ="wb")
  }
  if (!dir.exists("./R05")) {
      unzip("R05.zip")
  }
  </code></pre>
  
  <p>2) Then I load the shapefile with which I´ll construct the polygons.</p>
  
  <pre><code>distritos &lt;- readOGR( dsn= paste(getwd(), "/R05", sep = ""),
                    layer="Distritos_Censales", 
                    encoding = "UTF-8", stringsAsFactors = FALSE)
  </code></pre>
  
  <p>3) And select the administrative division I´m interested in</p>
  
  <pre><code> distritos &lt;- distritos[distritos@data$DESC_COMUN=="QUILPUÉ", ]
  </code></pre>
  
  <p>4) And then the  districts (polygons) I´m interested in:</p>
  
  <pre><code>distritos &lt;- distritos[distritos@data$DESC_DISTR=="EL RETIRO" |
                             distritos@data$DESC_DISTR=="BELLOTO NORTE" |
                             distritos@data$DESC_DISTR=="VALENCIA" | 
                             distritos@data$DESC_DISTR=="MENA" |
                             distritos@data$DESC_DISTR=="BELLOTO SUR" |
                             distritos@data$DESC_DISTR=="ALTO QUILPUÉ" |
                             distritos@data$DESC_DISTR=="EL SAUCE", ]
  </code></pre>
  
  <p>5) Construct the base map from the boundaries of <code>distritos</code>. For that,
  I use the function to get the center of a map from <a href="http://stackoverflow.com/questions/3081021/how-to-get-the-center-of-a-polygon-in-google-maps-v3">this</a> StackOverflow question</p>
  
  <pre><code>bbox(distritos)
  MapCenter &lt;- function(x1, y1, x2, y2){
      center.x &lt;- x1 + ((x2 - x1) / 2)
      center.y &lt;- y1 + ((y2 - y1) / 2)
      center &lt;- c(center.x, center.y)
      center
  }
  mcdistritos &lt;- MapCenter(bbox(distritos)[1,1], bbox(distritos)[2,1], 
  bbox(distritos)[1,2], bbox(distritos)[2,2])
  basemap &lt;- get_googlemap(mcdistritos, zoom = 13, 
                            maptype = "roadmap",
                            color = "bw",
                            style = "feature:administrative|element:labels|visibility:off")
  basemap &lt;- ggmap(basemap , extent = "device")
  </code></pre>
  
  <p>6) prepare the shapefile data to plot it with <code>ggplot2</code></p>
  
  <pre><code>distritos.fort &lt;- fortify(distritos, region = "DESC_DISTR")
  </code></pre>
  
  <p>7) Plot together both maps</p>
  
  <pre><code>basemap + 
  geom_polygon(data = distritos.fort, 
                      aes(x = long, y = lat),
                          colour = "black", 
                            fill = NA) + coord_map()
  </code></pre>
  
  <p>I tried by zooming out the base map, in case the polygon boundaries were messed up cause they didn´t fit in the base map, but I got the same result, just a smaller map. Does anyone know how to fix it?</p>