Created
July 7, 2011 14:20
-
-
Save jobjo/1069611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let options = new MapOptions(8, center, MapTypeId.ROADMAP) | |
let map = new Google.Maps.Map(mapElement.Body, options) | |
// Create the marker | |
let markerOption = new MarkerOptions(center) | |
markerOption.Map <- map | |
let marker = new Marker(markerOption) | |
// Function for setting mark the lat/long. | |
let setLatLong (latLong: LatLng) = | |
marker.SetPosition latLong | |
map.SetCenter latLong | |
{ | |
Location = "" | |
Latitude = latLong.Lat() | |
Longitude = latLong.Lng() | |
} | |
|> Result.Success | |
|> state.Trigger | |
// Search is either a given latitude and | |
// longitude or a text string. | |
match search with | |
| Choice1Of2 (lat, long) -> | |
setLatLong <| new LatLng(lat, long) | |
| Choice2Of2 location -> | |
// Create a Geo Coder | |
let geoCoder = Google.Maps.Geocoder() | |
let req = Google.Maps.GeocoderRequest() | |
req.Address <- location | |
geoCoder.Geocode(req, fun (res, status) -> | |
match List.ofArray res with | |
| r :: _ -> | |
setLatLong r.Geometry.Location | |
| [] -> | |
state.Trigger (Result.Failure []) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment