jmelosegui / GooglemapMvc

The control wraps Google maps API simplifying the use of Google maps in ASP.NET MVC applications.
MIT License
117 stars 61 forks source link

Updating model with latitude and longitude #135

Open dark-equinox opened 7 years ago

dark-equinox commented 7 years ago

Is there a way to update the model with the latitude and longitude from the geocoding service on the view? I am sending address to geocode, displaying on map. I would like to not make two calls to service to get the lat and long and update my form. @(Html.GoogleMap() .Name("map") .Width(200) .Height(200) .Center(c => c.Address(Model.Street + " " + Model.City + ", " + Model.State)) .Markers(m => m.Add().Title(Model.Street)) .Zoom(13)

I am new to MVC so I appreciate any help you can provide.

dark-equinox commented 7 years ago

Ok, so after going through all the issues, I can see that you can subscribe to event listeners. What I want to do is get the lat and long from a single marker and on dragend event show the lat and long on the form at dragend to save to database. the example I found was doing it server side, I want to handle this client side.

thanks

Micnick commented 7 years ago

Hi, do you have a example, I need update model from my map, and show it, in edit View, but the binding property no load the custom marker

<div style="height:100%; width:100%;"> @{ Html.GoogleMap() .Name("map") .Height(420) .MapTypeId(MapType.Hybrid) .ClientEvents(events => events .OnMapClick("mapClick") .OnMapLoaded("mapLoaded") ) .BindTo<WebApi.Models.RegionInfoModel,Marker> (pinInfo,mappings => mappings.For<WebApi.Models.RegionInfoModel> ( binding => binding.ItemDataBound ( (marker,regionInfo) => { marker.Latitude = regionInfo.Latitude; marker.Longitude = regionInfo.Longitude; marker.Title = regionInfo.Title; marker.ZIndex = regionInfo.ZIndex; marker.Clickable = true; } ) ) ) .Zoom(12) .ApiKey("zzz") .Center(c => c.UseCurrentPosition()) .Render(); } </div>