3

I've just started using WebSharper, and I'm trying to do something with the Google Maps API. I have been trying to implement the sample code from below: https://github.com/intellifactory/WebSharper.Google.Maps

open IntelliFactory.WebSharper.Google

[<JavaScript>]
let Sample buildMap =
    Div [Attr.Style "padding-bottom:20px; width:500px; height:300px;"]
    |>! OnAfterRender (fun mapElement ->
        let center = new Maps.LatLng(37.4419, -122.1419)
        let options = new Maps.MapOptions(center, MapTypeId.ROADMAP, 8)
        let map = new Maps.Map(mapElement.Dom, options)
        buildMap map)

But I can't find where the OnAfterRender method lives. I believe I've opened all the required namespaces, but there is no mention of it.

A cheap second question, is there a best database to use with WebSharper apps, or does it make no difference? Appharbor gives me the choice of: RavenDB, Microsoft SQL Server, MySQL, ElephantSQL, JustOneBD and MongoDB. I've got very little db experience, and I only need a very simple flatfile db.

Max Tilley
  • 1,509
  • 3
  • 10
  • 9

1 Answers1

2

OnAfterRender is defined in IntelliFactory.WebSharper.Html.Operators (as can be seen from here). It is sufficient to open IntelliFactory.WebSharper.Html (as Operators is marked with [<AutoOpen>]).


Regarding the database, there is nothing too important here. What you should make sure you have, before you make the decision, is:

  1. A .Net interface (usually exists, especially if AppHarbor offers that database)

  2. A good ORM that generates F#-usable classes. The definition of "F#-usable" is of course subjective, but make sure that the classes fits your coding style, otherwise you'll have to write your own ORM or your own wrappers around the ORM classes.

Ramon Snir
  • 7,520
  • 3
  • 43
  • 61
  • Ok, thanks for the advice. I'm still figuring out the effect of opening the namespaces in different orders. – Max Tilley Sep 03 '13 at 07:34
  • @MaxTilley yes, that's a bother. You can also make abbreviations for modules, if that helps. Look at many of the online WebSharper examples (both on the site, and on many blogs) and see how they organize the `open`s. – Ramon Snir Sep 03 '13 at 07:41