This is a migrated thread and some comments may be shown as answers.

Setting center after remote data is being called

1 Answer 34 Views
Map
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 29 Jul 2014, 07:27 AM
Hi,
I'm following the example "binding markers to remote data"
My question is: is it possible to center the map programmatically after the Datasource.read is being called? My datasource contains a list of possible stores. However, I would like to center the map (add a marker) with the initial longitude/latitude of my search request?

Next question : would it be possible (after datasource.read) to center/zoom the map around that layer?

So my code looks more or less as follow:
 @(Html.Kendo().Map()
    .Name("map")
    .Zoom(3)
    .Layers(layers =>
    {
        layers.Add()
            .Type(MapLayerType.Tile)
            .UrlTemplateId("http://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png")
            .Subdomains("a", "b", "c")
            .Attribution("&copy; <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>");

        layers.Add()
            .Type(MapLayerType.Marker)
            .DataSource(dataSource => dataSource
                  .Read(read => read.Action("_StoreLocations", "Order", new { OrderId = Request.QueryString["OrderId"] }))
                  )
            .LocationField("LatLng")

            .TitleField("Name");

    })

1 Answer, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 30 Jul 2014, 03:38 PM
Hello NS,

I think that you need to hook up to the DataSource change event and do this logic there.

I hope this helps.

Regards,
Hristo Germanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Map
Asked by
NS
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Share this question
or