def PolygonOptions(adict): """Accepts a dictionary of options. If necessary, transforms "paths" from python list or encoded string to javascript array.""" if adict.has_key("paths"): try: if isinstance(adict["paths"], (list, tuple)): adict["paths"] = listToJs(adict["paths"]) elif isinstance(adict["paths"], basestring): #Gmaps adict["paths"] = decodePoly(adict["paths"]) except: #isinstance throws exception for raw javascript objects. pass #That means it's already good. return dictToJs(adict)
def PolygonOptions(adict): """Accepts a dictionary of options. If necessary, transforms "paths" from python list or encoded string to javascript array.""" if adict.has_key("paths"): try: if isinstance(adict["paths"], (list, tuple)): adict["paths"] = listToJs(adict["paths"]) elif isinstance(adict["paths"], basestring): # Gmaps adict["paths"] = decodePoly(adict["paths"]) except: # isinstance throws exception for raw javascript objects. pass # That means it's already good. return dictToJs(adict)
def GeocoderRequest(**params): return dictToJs(params)
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __pyjamas__ import JS from pyjamas.gmaps.Utils import translateGmapsObject, dictToJs #, gmapsPyObjectToJs GeocoderStatus = JS("$wnd.google.maps.GeocoderStatus") GeocoderLocationType = JS("$wnd.google.maps.GeocoderLocationType") geocoderResultsFields = dictToJs( {"results": 'l', "types": 'l', "address_components": 'l', "results[]": 'd', "address_components[]": 'd', "geometry": 'd', "result": 'd'}) # translates a geocoderResults structure from js to python # and vice-versa def translateGeocoderResults(jsResults, pyToJs=False): return translateGmapsObject(jsResults, "results", \ geocoderResultsFields, pyToJs) # translates just one element of the geocoderResults # (because it is used inside directionsResults...) def translateGeocoderResult(jsResult, pyToJs=False): return translateGmapsObject(jsResult, "result", \
def InfoWindowOptions(**params): return dictToJs(params)
def NavigationControlOptions(**params): return dictToJs(params)
def DirectionsRequest(**params): return dictToJs(params)
def MarkerOptions(**params): return dictToJs(params)
def DirectionsRendererOptions(**params): return dictToJs(params)
def ScaleControlOptions(**params): return dictToJs(params)
def MapTypeControlOptions(**params): return dictToJs(params)
def MapOptions(**params): return dictToJs(params)
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __pyjamas__ import JS from pyjamas.gmaps.Utils import translateGmapsObject, dictToJs #, gmapsPyObjectToJs GeocoderStatus = JS("$wnd['google']['maps']['GeocoderStatus']") GeocoderLocationType = JS("$wnd['google']['maps']['GeocoderLocationType']") geocoderResultsFields = dictToJs({ "results": 'l', "types": 'l', "address_components": 'l', "results[]": 'd', "address_components[]": 'd', "geometry": 'd', "result": 'd' }) # translates a geocoderResults structure from js to python # and vice-versa def translateGeocoderResults(jsResults, pyToJs=False): return translateGmapsObject(jsResults, "results", \ geocoderResultsFields, pyToJs) # translates just one element of the geocoderResults
from pyjamas.gmaps.Utils import translateGmapsObject, dictToJs from pyjamas.gmaps.Geocoder import translateGeocoderResult DirectionsStatus = JS("$wnd.google.maps.DirectionsStatus") DirectionsTravelMode = JS("$wnd.google.maps.DirectionsTravelMode") DirectionsUnitSystem = JS("$wnd.google.maps.DirectionsUnitSystem") directionsResultsFields = dictToJs({ "trips": 'l', "warnings": 'l', "routes": 'l', "steps": 'l', "results": 'd', "trips[]": 'd', "routes[]": 'd', "steps[]": 'd', "start_geocode": translateGeocoderResult, "end_geocode": translateGeocoderResult }) # translates a directions results structure from js to python # and vice-versa def translateDirectionsResults(jsResults, pyToJs=False): return translateGmapsObject(jsResults, "results", \ directionsResultsFields, pyToJs)
from pyjamas.gmaps.Utils import translateGmapsObject, dictToJs from pyjamas.gmaps.Geocoder import translateGeocoderResult DirectionsStatus = JS("$wnd.google.maps.DirectionsStatus") DirectionsTravelMode = JS("$wnd.google.maps.DirectionsTravelMode") DirectionsUnitSystem = JS("$wnd.google.maps.DirectionsUnitSystem") directionsResultsFields = dictToJs( {"trips": 'l', "warnings": 'l', "routes": 'l', "steps": 'l', "results": 'd', "trips[]": 'd', "routes[]": 'd', "steps[]": 'd', "start_geocode": translateGeocoderResult, "end_geocode": translateGeocoderResult}) # translates a directions results structure from js to python # and vice-versa def translateDirectionsResults(jsResults, pyToJs=False): return translateGmapsObject(jsResults, "results", \ directionsResultsFields, pyToJs) class DirectionsService: