So I have this world map SVG and what I want is that when someone clicks on a country, that particular country gets highlighted and I can extract that country's name. How to achieve something like this in flutter?
Here is the SVG that I'm looking forward to using:
https://simplemaps.com/resources/svg-world
You could work with click coordinates:
Assign every country an interval of coordinates
Get click coordinates
Loop through coordinate-intervals
Find closest coordinate to click
Get country where coordinate belongs to
Show country-information on touch coordinates until new touch is registered
Highlighting the country wouldn't work this way. I believe there are librarys for working with vectors.
Related
UPD: Done. Look at this beautiful polygon.
UPD: In Flutter / openstreetmap, I want to let users draw a polygon by tapping a map and/or clicking a button. The polygon should be not filled. I need a very simple example just to get an idea of how it works.
The final task is:
I am making a flutter application that should give the user the ability to get information about markers located within a certain area on the map. I use osm. By pressing the button, the user initiates the construction of an arbitrary polygon, each corner of which is formed at the place of the next pressing of the button. When the construction of the polygon is completed, the objects inside the polygon are shown, the rest are hidden or not built. After that, the cycle ends by clearing the map.
I haven't found any solution for osm. I would appreciate any help. I don't have any code yet)
You can use the flutter_map library, I'm sure you can understand the documentation and how to set it up.
Then use PolygonLayerOptions(polygons: [Polygon(points: polygonList)]) as a layer on top of the OSM layer. Then set up the list polygonList and use the FlutterMap()'s onTap callback to get the position at which the user tapped and add the LatLng to the polygonList list. There are multiple other configuration options within the Polygon() constructor, and those can be found through IntelliSense or similar. To have no fill, just set the color to transparent.
I use this method (or a very similar one) for my app which lets users download areas of map. The user taps the top left and bottom right of a rectangular area they want to download, by code calculates the top right and bottom left, and a polygon is drawn to show the user exactly where they tapped. Make sure to use setState() or similar.
Let's say you want to build an app where people can find out whether the location the users are on has a risk of being flooded. You want to be able to create flood zone areas on the map and compare the user geolocation relative to the area. How do I do that with google_maps_flutter? or is there any other way to do it with plugins in flutter?
What I have in mind right now is to create polygons on the map and perform some geometric operations with it (if that is even possible). I have Esri SHP files which I will export to json and parse it in flutter and then use the results to draw polygons of the areas.
no code just yet..
You can make use of 'overlay widgets' in Flutter. You can draw, say a circle, indicating a flood zone with colour and radius in accordance with the probability (or other parameters).
Depending on how you want to display, you can create a separate UI control to display the comparision with reference to the user's geo-location.
I just wanted to enable only particular height-lighted country from entire google map to let the user select any location just like Android.
I referred so many link but the only shape I could monitor is circular not country shape.
I have a string of lat longs of whole country.
I referred so many link but the only shape I could monitor is circular not country shape.
Unfortunately, iOS currently only lets you monitor circular regions, which means that you'll need to do some more work to monitor arbitrary-shaped regions. You'll want to do something like:
Create a circular region that's tangent to the nearest border and start monitoring it.
When you get a notification that the user has moved outside the region, check to see whether they've crossed the border. If not, remove the current region and go to step 1.
Hello everyone i am stuck into one problem. I am working on Application in which Mall Map required to integrate.
I need to display Mall map like this:
I have done proper r&d but not found any solution yet.
Can it be possible if yes then how can i implement this ?
Any hint or suggestion will be appreciated.
Thanks.
You could display the map in a UIImage and place this image in a UIScrollView. After that you need to divide the image into region rectangles, each identifying one room.
When the user taps the UIScrollView you need to determine which region he tapped on.
Using your room grid you can detect which room he tapped on. Of course this is easier for not zoomed images.
In a zoomed state you need to convert the touched point to the "unzoomed touched point" and check this point for the grid.
I am using CLLocationManager to retrieve current location in my app and display using MapView, i want to slide the map so that the current location should also change to the new location where the map slides and it should annotate to the new location, how to do it? Please give your suggestions with sample code.
You probably don't mean "the current" since that means where the phone actually is, unless you want to transport the phone to another place when using this app which would be quite a feat. So, how about drawing a layer over the top of your map that keeps a pin drawn at the centre so it looks as if the pin is moving over the map, but really the map is moving under the pin.