Hi,
I am using Thinkgeo MVC Suite and I want more zooming on map,
As currently from zooming bar I was zoom up to the limit of zoom bar,
but I want more zoom to display object perfect,
So is it possible? and if possible then how can I do this?
More zooming on map
seems possible: wiki.thinkgeo.com/wiki/Map_Suite_Style_Guide
go to the section: Creating New ZoomLevels
Hi,
guangming is right, the solution is create custom zoomlevelset for zoom deeper.
Thanks for guangming’s share.
Regards,
Don
Thanks guangming and Don
I create a map using below code
Dim MapBuilder = Html.ThinkGeo.Map("Map1", New System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), 530)
MapBuilder.MapBackground(New BackgroundLayer(New GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))))
MapBuilder.MapUnit(GeographyUnit.Meter)
MapBuilder.MapTools(Sub(tools)
tools.OverlaySwitcherMapTool().Enabled(False)
tools.MouseCoordinateMapTool().Enabled(False)
tools.KeyboardMapTool().Enabled(True)
tools.LoadingImageMapTool().Enabled(True)
tools.MiniMapMapTool().Enabled(True)
End Sub)
MapBuilder.CurrentExtent(xxxxxxxxxxxx, xxxxxxxxxxxx, xxxxxxxxxxxx, xxxxxxxxxxxxxx)
MapBuilder.CustomOverlays(Sub(overlays)
overlays.GoogleOverlay("Google Map").JavaScriptLibraryUri(New Uri(ConfigurationManager.AppSettings("GoogleUriV3"))).GoogleMapType(GoogleMapType.Normal)
'Add different layers on map.
End Sub)
End With
End Sub)
So at which place I put the custom zoom level code I am using MVC 3, so I am little bit confuse,
So can you please help me in this?
you create the customized zoomlevelset, then apply to your layer. Each layer can have different zoom level set.
// Create the ZoomLevels
ZoomLevel zoomLevel1 = new ZoomLevel(100000);
ZoomLevel zoomLevel2 = new ZoomLevel(50000);
ZoomLevel zoomLevel3 = new ZoomLevel(25000);
// Create a new ZoomLevelSet
ZoomLevelSet zoomLevelSet = new ZoomLevelSet();
// Add the ZoomLevels to the ZoomLevelSet
zoomLevelSet.CustomZoomLevels.Add(zoomLevel1);
zoomLevelSet.CustomZoomLevels.Add(zoomLevel2);
zoomLevelSet.CustomZoomLevels.Add(zoomLevel3);
// Apply the new ZoomLevelSet to your FeatureLayer
shapefileFeatureLayer.ZoomLevelSet = zoomLevelSet;
Thanks guangming
As I am using MsSql2008FeatureLayer layer and I am using more that 8 different MsSql2008FeatureLayer on map, so can you give me the idea how can I use zoomlevelset in this.
I use below code to add MsSql2008FeatureLayer on map
Dim layer1 As MsSql2008FeatureLayer = New MsSql2008FeatureLayer(connectString, "layer1", "OBJECTID", xxxxxx)
layer1 .Open()
layer1 .ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.DarkMagenta
layer1 .ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
if all your feature layers are using the same zoom level set, you can just create one instance of the ZoomLevelSet and set the right scales you want, then just assign that zoom level set to each layer.
If one layer is using different rules for zooming, you have to create a new zoom level set instance and assign it to the layer.
It should work.
BTW, you do not need to Open the layer in order to add it to your map, in my opinion.
Good luck,
Hi,
I have also try to assign zoom level set as you said, but it is not working,
So can you provide me some sample code according to I add the layer on map.
Thanks
Hi Vivek&Guangming,
Since we want to assign the custom zoomlevels for the whole map, I think the best solution is we give a customZoomlevel for the map level rather than the layer level.
Besides, I notice Vivek is defining the map in the view page, I would suggest we should put all the map defined in the controller if your logic is complex. In order to make things clear, I created a custom zoomlevel map sample which works fine with Google and Bing map, please get it and have a try.
Any questions don’t hesitate to let us know.
Thanks,
Troy
CustomZoomlevelOverGoogleBing.zip (1.85 KB)
Thank You Very Much Troy
It’s work perfect…
But now I face one issue related to marker as I zoomToExtent were marker is put on map
and in my marker zoomlevel is upto 20, so no any marker is display.
I am add marker on map using:
With overlays.InMemoryMarkerOverlay(“MarkerOverlay”).IsVisibleInOverlaySwitcher(False)
.ZoomLevelSet(Sub(markerZoomLevelSet)
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.ContentHtml = “” + Request.QueryString(“Name”) + ""
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.HasCloseButton = True
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.Width = 180
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.Height = 30
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BackgroundColor = GeoColor.StandardColors.LightBlue
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderColor = GeoColor.StandardColors.Black
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderWidth = 1
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5F
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetY = -25.0F
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageWidth = 21
markerZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageHeight = 25
markerZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
End Sub)
End With
So how can I set custom zoomlevel in marker,
can you please help me in this??
Thanks
Hi Vivek,
Good to hear it helps.
For the new question, would you please try the customZoomlevels for markerZoomlevelset. something like the below, let’s say we have a customed 25 zoomlevels:
MarkerZoomLevelSet markerZoomLevelSet =
new
MarkerZoomLevelSet();
for
(
int
i = 0; i < 25; i++)
{
MarkerZoomLevel zoomlevel =
new
MarkerZoomLevel();
// ‘’’’
markerZoomLevelSet.CustomZoomLevels.Add(zoomlevel);
}
Please let me know if any questions.
Thanks,
Troy
Thanks Troy
Its works
Vivek, You are welcome.
Thanks,
Troy
Hi Troy,
I have one problem during set custom zoom level in Overlays layer.
I have added overlays layer on map as below:
Dim MapBuilder = Html.ThinkGeo.Map("Map1", New System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), New System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage))
MapBuilder.MapBackground(New BackgroundLayer(New GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))))
MapBuilder.MapUnit(GeographyUnit.Meter)
MapBuilder.CurrentExtent(-xxxxxxxxxxx, xxxxxxxxxxxx, xxxxxxxxxxxx, xxxxxxxxx)
MapBuilder.ZoomLevelSet(moreZoomlevelset)
MapBuilder.CustomOverlays(Sub(overlays)
overlays.GoogleOverlay("Google Map").JavaScriptLibraryUri(New Uri(ConfigurationManager.AppSettings("GoogleUriV3"))).GoogleMapType(GoogleMapType.Normal)
Dim M As MsSql2008FeatureLayer = New MsSql2008FeatureLayer(connectString, "Mapa_Edificacao", "OBJECTID", 32723)
M.Open()
M.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.DarkGoldenrod
M.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
Dim proj3 As Proj4Projection = New Proj4Projection()
proj3.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32723)
proj3.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
proj3.Open()
M.FeatureSource.Projection = proj3
overlays.LayerOverlay("M", False, TileType.SingleTile).Layer("M", M).IsVisible(False)
// More layers like above
End Sub).OnClientClick("mapClickToEdit").Render()
I have set morezoomlevel as you said in above post and set to Map like:
Mapbuilder.zoomlevelset(morezoomlevel)
So how can I set custom zoom level to above layers.
Hi Vivek,
I think this is more similar with what we did in MarkerZoomLevelSet above. We just need to add the zoomlevels into the CustomZoomlevel property of the ShapefileFeatureLayer and don’t need to do anything on the pre-defined Zoomlevel01 style, some codes like the below:
Dim M As MsSql2008FeatureLayer = New MsSql2008FeatureLayer(connectString, “Mapa_Edificacao”, “OBJECTID”, 32723)
M.Open()
for (int i = 0; i < 25; i++)
{
ZoomLevel zoomlevel = new ZoomLevel();
// ‘’’’
MsSql2008FeatureLayer.ZoomLevelSet.CustomZoomLevels.Add(zoomlevel);
}
Dim proj3 As Proj4Projection = New Proj4Projection()
proj3.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32723)
proj3.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
proj3.Open()
M.FeatureSource.Projection = proj3
overlays.LayerOverlay(“M”, False, TileType.SingleTile).Layer(“M”, M).IsVisible(False)
Any questions don’t hesitate to let us know.
Thanks,
Troy
Thanks Troy,
I have used above code but still problem is not resolved.
When I zoom above 20 my map shown like below:
and also using your code layer is not display when I have load the map.
I am adding custom zoom level to mapbuilder because I am using mapbuilder to create map, so I am using below code to set zoom level to mapbuilder
Dim moreZoomlevelset As New ZoomLevelSet()
Dim googlezoomlevelsets As New GoogleMapsZoomLevelSet()
For Each item As ZoomLevel In googlezoomlevelsets.GetZoomLevels()
moreZoomlevelset.CustomZoomLevels.Add(item)
Next
Dim zoomlevel21 As New ZoomLevel(moreZoomlevelset.GetZoomLevels()(moreZoomlevelset.GetZoomLevels().Count - 1).Scale / 2)
Dim zoomlevel22 As New ZoomLevel(zoomlevel21.Scale / 2)
Dim zoomlevel23 As New ZoomLevel(zoomlevel22.Scale / 2)
Dim zoomlevel24 As New ZoomLevel(zoomlevel23.Scale / 2)
moreZoomlevelset.CustomZoomLevels.Add(zoomlevel21)
moreZoomlevelset.CustomZoomLevels.Add(zoomlevel22)
moreZoomlevelset.CustomZoomLevels.Add(zoomlevel23)
moreZoomlevelset.CustomZoomLevels.Add(zoomlevel24)
Dim MapBuilder = Html.ThinkGeo.Map(“Map1”, New System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), New System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage))
MapBuilder.MapBackground(New BackgroundLayer(New GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))))
MapBuilder.MapUnit(GeographyUnit.Meter)
MapBuilder.ZoomLevelSet(moreZoomlevelset)
MapBuilder.MapTools(Sub(tools)
tools.OverlaySwitcherMapTool().Enabled(False)
tools.MouseCoordinateMapTool().Enabled(False)
tools.KeyboardMapTool().Enabled(False)
tools.LoadingImageMapTool().Enabled(True)
tools.MiniMapMapTool().Enabled(True)
End Sub)
MapBuilder.CurrentExtent(xxxxxxx, xxxxxxxxx, -xxxxxxx, xxxxxx)
So is this a reason to crash layer after zoomlevel 20?
Am I do anything wrong to set zoomlevel?
If is it possible then give me some demo code
Hi Vivek,
I think I might make mistakes at the previous reply that I said we just need to define the customZoomlevels for the map level. Actually, In order to make the layers render with the specified styles beyond the default zoomlevels(20), we still need to define the customZoomlevels on the layer level. That’s provide the way to set difference styles for each custom zoomlevel. So, please add the missing codes below on your layers:
Dim shapefileFeatureLayer As ShapeFileFeatureLayer
For index = 1 To 25
Dim zoomLevel As ZoomLevel
'set style or some other property of zoomLevel.
zoomLevel.DefaultAreaStyle = …
shapefileFeatureLayer.ZoomLevelSet.CustomZoomLevels.Add(zoomLevel)
Next
If the issue persists, don’t hesitate to let us know.
Thanks,
Troy
Thanks for the reply.
When map loaded that time all the layers display perfectly for all zoom levels, but when I put marker on map and zoom after zoomlevel 20 that time, no any layer is display means its crash like image shown in my previous post. Marker as well as map display perfectly, but all layer on the map is crash.
I have set custom zoom level for marker as well as map as you told me in older post.
So what is the solution for this?
Hi Vivek,
Seems you are facing another issue and we can’t
recreate it based on your codes. Here I attached a sample which is similar with
yours and would you please modify it to recreate your issue and then send it to
us?
Also, I took a test video to show how it works
fine in my end with the sample. screencast.com/t/ztg2tZ4NW
Thanks,
Troy
DisplayASimpleMapVBMVC.zip (1.44 MB)
Thanks Troy for the reply,
Yes I have used same code as code in your sample.
All layers works perfectly until I added marker on map.
I just add marker overlay on map using below code in
view side:
With overlays.InMemoryMarkerOverlay("MarkerOverlay").IsVisibleInOverlaySwitcher(False)
.ZoomLevelSet(Sub(markerZoomLevelSet)
Dim zoomlevelm As New MarkerZoomLevel()
zoomlevelm.DefaultMarkerStyle.Popup.ContentHtml = "" + Request.QueryString("Name") + ""
zoomlevelm.DefaultMarkerStyle.Popup.HasCloseButton = True
zoomlevelm.DefaultMarkerStyle.Popup.Width = 180
zoomlevelm.DefaultMarkerStyle.Popup.Height = 30
zoomlevelm.DefaultMarkerStyle.Popup.BackgroundColor = GeoColor.StandardColors.LightBlue
zoomlevelm.DefaultMarkerStyle.Popup.BorderColor = GeoColor.StandardColors.Black
zoomlevelm.DefaultMarkerStyle.Popup.BorderWidth = 1
zoomlevelm.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5F
zoomlevelm.DefaultMarkerStyle.WebImage.ImageOffsetY = -25.0F
zoomlevelm.DefaultMarkerStyle.WebImage.ImageWidth = 21
zoomlevelm.DefaultMarkerStyle.WebImage.ImageHeight = 25
For i As Integer = 0 To 24
markerZoomLevelSet.CustomZoomLevels.Add(zoomlevelm)
Next
End Sub)
End With
In controller side:
markerId = args("markerId").ToString()
Dim x as string = args("x").ToString()
Dim y as string = args("y").ToString()
Dim markerOverlay As InMemoryMarkerOverlay = map.CustomOverlays("MarkerOverlay")
markerOverlay.Features.Clear()
If Not markerOverlay.FeatureSource.InternalFeatures.Contains(markerId) Then
Dim proj10 As Proj4Projection = New Proj4Projection()
proj10.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32723)
proj10.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
proj10.Open()
map.MapUnit = GeographyUnit.Meter
markerOverlay.FeatureSource.Projection = proj10
markerOverlay.FeatureSource.InternalFeatures.Add(markerId, New Feature(x, y))
When user click on any one data from no. of data, that time marker will add on map,
so after marker is add on map, all other layer is crash after zoom level 20.