Comments (10)
Could you give use case?
Also example in JavaScript or elsewere?
from blazorgooglemaps.
This is the code in the browser.
GoogleMap map1;
MapOptions mapOptions;
protected override async Task OnInitializedAsync() {
MapsCoordinatesBindingModel mapsCoordinates =
await Task.Run(() => {
return service
.GetCoordinates("СПИДИ София - Младост 3 (жк), бл. 319, ж.к. Младост 3, София")
.Result;
});
mapOptions = new MapOptions() {
Zoom = 13,
Center = new LatLngLiteral() {
Lat = mapsCoordinates.Lat,
Lng = mapsCoordinates.Lng
},
MapTypeId = MapTypeId.Sattellite
};
}
}
I am using Geocoding to get coordinates of a place.
from blazorgooglemaps.
Thank you. I will take a look today.
from blazorgooglemaps.
Could you provide full example? You could remove or change sensitive data.
I dont understand what is service. What is MapsCoordinatesBindingModel. Also i dont understand what you are trying to archive.
Maybe you could try to download GitHub solution and tryout MapAutocomplete page on server side. You could debut it and it will help you find how it works. I think you need Autocomplete.GetPlace method call.
from blazorgooglemaps.
To make Autocomplete work, you need something like the following:
<input type="text" @ref="this.searchBox" id="searchBox" />
<GoogleMap @ref="@map1" Id="map1" Options="@mapOptions" Height="500" OnAfterInit="@(async () => await OnAfterMapInitAsync())"></GoogleMap>
@code {
private GoogleMap map1;
private MapOptions mapOptions;
private ElementReference searchBox;
private Autocomplete autocomplete;
protected override void OnInitialized()
{
this.mapOptions = new MapOptions
{
Zoom = 13,
Center = new LatLngLiteral
{
Lat = 40.621875,
Lng = -74.125255
},
MapTypeId = MapTypeId.Roadmap
};
}
private async Task OnAfterMapInitAsync()
{
this.autocomplete = await Autocomplete.CreateAsync(this.map1.JsRuntime, this.searchBox, new AutocompleteOptions
{
StrictBounds = false
});
await this.autocomplete.AddListener("place_changed", async () => await this.MapSearchPlaceChanged());
}
private async Task MapSearchPlaceChanged()
{
var place = await this.autocomplete.GetPlace();
if (place?.Geometry?.Location != null)
{
// do something with the place.Geometry.Location
}
}
}
from blazorgooglemaps.
I want to ask how I can use MapAutocomplete from the library?
from blazorgooglemaps.
Could you confirm it is it what you want to do.
Pass address name "СПИДИ София - Младост 3 (жк), бл. 319, ж.к. Младост 3, София" or similar
Get first coordinates (lat, lng) from result
Return that coordinates
Am i right?
from blazorgooglemaps.
Yes.
from blazorgooglemaps.
It looks like you need geocoding which is not implemented in here. It is not directly related to google maps. I dont want to spend time implementing it here since there are already libraries who does that.
After you get lat lng then you could set it to map
await this.map1.InteropObject.SetCenter(new LatLngLiteral(){ Lat = 12.12 , Lng = 25.25});
Here is nuget for that
https://github.com/chadly/Geocoding.net
Examples on stackoverflow
https://stackoverflow.com/questions/16274508/how-to-call-google-geocoding-service-from-c-sharp-code
from blazorgooglemaps.
Closing due innactivity.
from blazorgooglemaps.
Related Issues (20)
- Need API documentation and support on Stack Overflow HOT 6
- Accessing the map object via javascript HOT 4
- Working with encoded polylines. HOT 2
- Multiple Ground Overlays HOT 3
- DrawingManager.SetDrawingMode no longer works in 3.3.2 and newer HOT 7
- Add class DragEndEvent for dragend listener (Suggestion) HOT 1
- MarkerClustering - Set Click on Zoom level; HOT 2
- polygonList not rendering the polygons HOT 9
- Advanced Markers server side demo dont work anymore HOT 4
- Link KeyProvider to map object scope instead of application level static HOT 2
- Advanced Marker Support HOT 4
- AdvancedMapMarker Microsoft.JSInterop.JSException: function not found HOT 1
- Enabling Dependabot for repository
- AdvancedMarkerElementOptions - Content Invalid (not an instance of Node) HOT 13
- New method services.AddBlazorGoogleMaps("YOUR_KEY_GOES_HERE"); only is used in Maps, not other components HOT 1
- Blazor web app demo HOT 1
- Removed map HTMLElement from DOM still try to render map HOT 14
- Add Support for PinElement (AdvancedMarkerElement Customization) HOT 8
- AdvancedMarker from svg HOT 4
- Add way to set AdvancedMarker properties HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazorgooglemaps.