0

Gmaps.store.handler.getMap().zoomTo(10) gives me Uncaught TypeError: Object #<pi> has no method 'zoomTo'

Directly above that, I call Gmaps.store.handler.map.centerOn, with a lat and lng, and it centers properly, so I'm inclined to believe that the handler is right. I call handler with

Gmaps.store = {} #handler, markers, userPin, eventPin
jQuery ->
  Gmaps.store.handler = Gmaps.build 'Google'    
  Gmaps.store.handler.buildMap { internal: {id: 'map'} }, ->
    Gmaps.store.markers = Gmaps.store.handler.addMarkers( $('#map').data('events'), 
      draggable: false
      flat: false
      animation: google.maps.Animation.DROP
    )

    google.maps.event.addListener Gmaps.store.handler.getMap(), 'click', (event) ->
    addEventMarker event.latLng if $('#createEventWindow').is(':visible')

Also, when calling Gmaps.store.handler.bounds, I'm getting 180 and 1. Shouldn't I be able to call .getNorthEast() on the bounds as well? Console tells me there is no such function. Here's a pic of the beast...

map showing San Diego, bounds are botched

Update

updateSearchLocation = ->
  if $('#collapseOne input#location').val()
    geocoder = new google.maps.Geocoder()
    address = $('#collapseOne input#location').val()
    geocoder.geocode address: address, (results, status) ->
      if status is google.maps.GeocoderStatus.OK
        latLng = results[0].geometry.location
        Gmaps.store.handler.map.centerOn
          lat: latLng.lat()
          lng: latLng.lng()
        Gmaps.store.handler.getMap().setZoom(10)
        console.log Gmaps.store.handler.bounds.getServiceObject().getNorthEast()
        $('#collapseOne input#ne').val Gmaps.store.handler.bounds.getServiceObject().getNorthEast()
        $('#collapseOne input#sw').val Gmaps.store.handler.bounds.getServiceObject().getSouthWest()
      else
        throw status + ' for ' + address
4

1 回答 1

2

谷歌设置缩放的方法是setZoom,所以:

handler.getMap().setZoom(10)

对于边界,自定义对象存储在这里:

handler.bounds

像所有自定义对象一样handler.map或标记,如果您需要访问 google 对象,您可以使用getServiceObject()

handler.bounds.getServiceObject()
handler.map.getServiceObject() # same as handler.getMap()
markers[0].getServiceObject()
...
于 2013-11-14T07:34:04.450 回答