Exemple #1
0
        private void SerializeMapTypes(ClientSideObjectWriter objectWriter)
        {
            if (this.ImageMapTypes.Any())
            {
                if (!this.ImageMapTypes.Select(mt => mt.MapTypeName).Contains(this.MapTypeId))
                {
                    throw new InvalidOperationException("Cannot find the MapTypeId in the ImageMapTypes collection");
                }

                var mapTypes = new List <IDictionary <string, object> >();

                this.ImageMapTypes.Each(m => mapTypes.Add(m.CreateSerializer().Serialize()));

                if (mapTypes.Any())
                {
                    objectWriter.AppendCollection("imageMapTypes", mapTypes);
                }
            }

            if (this.StyledMapTypes.Any())
            {
                var mapTypes = new List <IDictionary <string, object> >();

                this.StyledMapTypes.Each(m => mapTypes.Add(m.CreateSerializer().Serialize()));

                if (mapTypes.Any())
                {
                    objectWriter.AppendCollection("styledMapTypes", mapTypes);
                }
            }
        }
Exemple #2
0
        public void SerializeTo(ClientSideObjectWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.AppendClientEvent("bounds_changed", this.OnMapBoundChanged);
            writer.AppendClientEvent("center_changed", this.OnMapCenterChanged);
            writer.AppendClientEvent("click", this.OnMapClick);
            writer.AppendClientEvent("dblclick", this.OnMapDoubleClick);
            writer.AppendClientEvent("rightclick", this.OnMapRightClick);
            writer.AppendClientEvent("drag", this.OnMapDrag);
            writer.AppendClientEvent("dragend", this.OnMapDragEnd);
            writer.AppendClientEvent("dragstart", this.OnMapDragStart);
            writer.AppendClientEvent("heading_changed", this.OnMapHeadingChanged);
            writer.AppendClientEvent("idle", this.OnMapIdle);
            writer.AppendClientEvent("maptypeid_changed", this.OnMapTypeIdChanged);
            writer.AppendClientEvent("mousemove", this.OnMouseMove);
            writer.AppendClientEvent("mouseout", this.OnMouseOut);
            writer.AppendClientEvent("mouseover", this.OnMouseOver);
            writer.AppendClientEvent("projection_changed", this.OnMapProjectionChanged);
            writer.AppendClientEvent("resize", this.OnResize);
            writer.AppendClientEvent("tilesloaded", this.OnTilesLoaded);
            writer.AppendClientEvent("resize", this.OnTiltChanged);
            writer.AppendClientEvent("zoom_changed", this.OnZoomChanged);
            writer.AppendClientEvent("map_loaded", this.OnMapLoaded);
            writer.AppendClientEvent("markers_geocoding_completed", this.OnMarkersGeocodingCompleted);
            writer.AppendClientEvent("markers_geocoding_progress", this.OnMarkersGeocodingProgress);
        }
Exemple #3
0
        private void SerializeMarkers(ClientSideObjectWriter objectWriter)
        {
            if (this.EnableMarkersClustering)
            {
                objectWriter.AppendObject("markerClusteringOptions", this.MarkerClusteringOptions.Serialize());
            }

            if (this.Markers.Any())
            {
                var markers = new List <IDictionary <string, object> >();
                int i       = 0;
                this.Markers.Each(m =>
                {
                    if (string.IsNullOrWhiteSpace(m.Id))
                    {
                        m.Id = i.ToString(CultureInfo.InvariantCulture);
                    }
                    markers.Add(m.CreateSerializer().Serialize());
                    i++;
                });

                if (markers.Any())
                {
                    objectWriter.AppendCollection("markers", markers);
                }

                objectWriter.AppendClientEventObject("markerEvents", this.MarkerClientEvents);
            }
        }
Exemple #4
0
        public void SerializeTo(ClientSideObjectWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.AppendClientEvent("animation_changed", this.OnMarkerAnimationChanged);
            writer.AppendClientEvent("click", this.OnMarkerClick);
            writer.AppendClientEvent("clickable_changed", this.OnMarkerClickableChanged);
            writer.AppendClientEvent("cursor_changed", this.OnMarkerCursorChanged);
            writer.AppendClientEvent("dblclick", this.OnMarkerDoubleClick);
            writer.AppendClientEvent("dragstart", this.OnMarkerDragStart);
            writer.AppendClientEvent("drag", this.OnMarkerDrag);
            writer.AppendClientEvent("dragend", this.OnMarkerDragEnd);
            writer.AppendClientEvent("flat_changed", this.OnMarkerFlatChanged);
            writer.AppendClientEvent("icon_changed", this.OnMarkerIconChanged);
            writer.AppendClientEvent("mousedown", this.OnMarkerMouseDown);
            writer.AppendClientEvent("mouseout", this.OnMarkerMouseOut);
            writer.AppendClientEvent("mouseover", this.OnMarkerMouseOver);
            writer.AppendClientEvent("mouseup", this.OnMarkerMouseUp);
            writer.AppendClientEvent("position_changed", this.OnMarkerPositionChanged);
            writer.AppendClientEvent("rightclick", this.OnMarkerRightClick);
            writer.AppendClientEvent("shape_changed", this.OnMarkerShapeChanged);
            writer.AppendClientEvent("title_changed", this.OnMarkerTitleChanged);
            writer.AppendClientEvent("visible_changed", this.OnMarkerVisibleChanged);
            writer.AppendClientEvent("zindex_changed", this.OnMarkerZIndexChanged);
        }
Exemple #5
0
        protected internal virtual void WriteInitializationScript(TextWriter writer)
        {
            var currentCulture = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            var objectWriter = new ClientSideObjectWriter(this.Id, "GoogleMap", writer);

            objectWriter.Start();

            objectWriter.Append("clientId", this.Id);
            objectWriter.Append("disableDoubleClickZoom", this.DisableDoubleClickZoom, false);
            objectWriter.Append("draggable", this.Draggable, true);
            objectWriter.Append("enableMarkersClustering", this.EnableMarkersClustering, false);
            objectWriter.Append("markersFromAddress", this.MarkersGeocoding, false);
            objectWriter.Append("fitToMarkersBounds", this.FitToMarkersBounds, false);

            if (this.Address.HasValue())
            {
                objectWriter.AppendObject("center", new { this.Address });
            }
            else
            {
                objectWriter.AppendObject("center", new { this.Latitude, this.Longitude, this.UseCurrentPosition });
            }

            objectWriter.Append("mapTypeId", this.MapTypeId);
            objectWriter.Append("mapTypeControlPosition", this.MapTypeControlPosition, ControlPosition.TopRight);
            objectWriter.Append("mapTypeControlVisible", this.MapTypeControlVisible, true);
            objectWriter.Append("mapTypeControlStyle", this.MapTypeControlStyle, MapTypeControlStyle.Default);
            objectWriter.Append("panControlPosition", this.PanControlPosition, ControlPosition.TopLeft);
            objectWriter.Append("panControlVisible", this.PanControlVisible, true);
            objectWriter.Append("overviewMapControlVisible", this.OverviewMapControlVisible, false);
            objectWriter.Append("overviewMapControlOpened", this.OverviewMapControlOpened, false);
            objectWriter.Append("streetViewControlVisible", this.StreetViewControlVisible, true);
            objectWriter.Append("scrollwheel", this.ScrollWheel, true);
            objectWriter.Append("streetViewControlPosition", this.StreetViewControlPosition, ControlPosition.TopLeft);
            objectWriter.Append("zoomControlVisible", this.ZoomControlVisible, true);
            objectWriter.Append("zoomControlPosition", this.ZoomControlPosition, ControlPosition.TopLeft);
            objectWriter.Append("zoomControlStyle", this.ZoomControlStyle, ZoomControlStyle.Default);
            objectWriter.Append("scaleControlVisible", this.ScaleControlVisible, false);
            objectWriter.Append("zoom", (this.Zoom == 0) ? 6 : this.Zoom, 6);
            objectWriter.Append("minZoom", this.MinZoom, 0);
            objectWriter.Append("maxZoom", this.MaxZoom, 0);

            this.SerializeLyers(objectWriter);
            this.SerializeMapTypes(objectWriter);
            this.SerializeMarkers(objectWriter);
            this.SerializeShapes(objectWriter);

            this.ClientEvents.SerializeTo(objectWriter);

            // TODO: Call a virtual method OnCompleting to allow derived class to inject its own json objects
            objectWriter.Complete();

            Thread.CurrentThread.CurrentCulture = currentCulture;
        }
Exemple #6
0
        private void SerializeLyers(ClientSideObjectWriter objectWriter)
        {
            if (this.Layers.Any())
            {
                var layers = new List <IDictionary <string, object> >();

                this.Layers.Each(l => layers.Add(l.CreateSerializer().Serialize()));

                if (layers.Any())
                {
                    objectWriter.AppendCollection("layers", layers);
                }
            }
        }
Exemple #7
0
        private void SerializeShapes(ClientSideObjectWriter objectWriter)
        {
            if (this.Polylines.Any())
            {
                var polylines = new List <IDictionary <string, object> >();

                this.Polylines.Each(p => polylines.Add(p.CreateSerializer().Serialize()));

                if (polylines.Any())
                {
                    objectWriter.AppendCollection("polylines", polylines);
                }
            }

            if (this.Polygons.Any())
            {
                var polygons = new List <IDictionary <string, object> >();

                this.Polygons.Each(p => polygons.Add(p.CreateSerializer().Serialize()));

                if (polygons.Any())
                {
                    objectWriter.AppendCollection("polygons", polygons);
                }
            }

            if (this.Circles.Any())
            {
                var circles = new List <IDictionary <string, object> >();

                this.Circles.Each(c => circles.Add(c.CreateSerializer().Serialize()));

                if (circles.Any())
                {
                    objectWriter.AppendCollection("circles", circles);
                }
            }
        }