Beispiel #1
0
        internal GoogleMapWrapper(IGoogleMapHost browser, MapOptions mapOptions, StreetViewOptions streetViewOptions, string apiKey = null, bool sensor = false, string regionString = null)
        {
            _markers        = new Dictionary <int, Marker>();
            _polygons       = new Dictionary <int, Polygon>();
            _circles        = new Dictionary <int, Circle>();
            _infoWindows    = new Dictionary <int, InfoWindow>();
            _polylines      = new Dictionary <int, Polyline>();
            _groundOverlays = new Dictionary <int, GroundOverlay>();
            _rectangles     = new Dictionary <int, Rectangle>();

            _browser = browser;

            ApiKey       = apiKey;
            Sensor       = sensor;
            RegionString = regionString;

            _mapOptions        = mapOptions;
            _streetViewOptions = streetViewOptions;
            _zoom   = mapOptions.Zoom;
            _center = mapOptions.Center;

            StringBuilder documentBuilder = new StringBuilder();

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(String.Format("{0}.Map.html", this.GetType().Namespace)))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        var line = reader.ReadLine();
                        documentBuilder.AppendLine(line);

                        if (line == "<head>")
                        {
                            //Inject JQuery scripts
                            documentBuilder.AppendLine(GetScriptText());
                        }
                    }
                }
            }
            _browser.SetHostDocumentText(documentBuilder.ToString());
            _browser.RegisterScriptingObject(this);
            _documentLoaded = true;
            _streetView     = new StreetView(_browser);
            _geometry       = new Geometry(_browser);
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new Google Map
 /// </summary>
 /// <param name="host">Browser host to host Google Maps i</param>
 /// <param name="mapOptions">Customize the look of the map</param>
 /// <param name="streetViewOptions">Customize the look of the street view panormama</param>
 /// <param name="apiKey">API key (Optional, but if required visit this site: "https://code.google.com/apis/console/")</param>
 /// <param name="sensor">Whether calling from a sensor. Defaults to false.</param>
 /// <param name="regionString">Country code (ie. "za"). Defaults to NULL</param>
 /// <returns>Interface to interact with Google Maps</returns>
 public static IGoogleMapWrapper Create(IGoogleMapHost host, MapOptions mapOptions, StreetViewOptions streetViewOptions, string apiKey = null, bool sensor = false, string regionString = null)
 {
     return(new GoogleMapWrapper(host, mapOptions, streetViewOptions, apiKey, sensor, regionString));
 }