Thanks for the video. How do you draw the very first shape? I noticed as soon as you click onto he map the shape was drawn.
When you use the Draw Shape action, each shape can be given a shape ID (it’s always automatically generated too) and can be retrieved from the “shape id” state.
There’s an action called Remove Shape where you can pass that same shape ID back into, then the shape gets removed from the map.
Hmm… i dont think I’m skilled enough yet to figure that one out on my own. Thank you, i wish there was some kind of tutorial or guid from somelnes thats built this. I’ll have to dig in and figure it out i think.
I use this site (All States and Territories in the United States of America - KML Boundary File Download) in conjunction with the Extract KML features included in this plugin to get the boundaries and draw the shapes on the map. The only thing I haven’t gotten it to do is import zip codes with multiple shapes (like when a zip code is split into multiple separate polygons) and had to creatively find a way to identify the zip code when importing the full state. I don’t see where in the plugin I can extract coordinates in conjunction with the zip name but maybe @pork1977gm knows of a foolproof way to do that?
I’m enjoying this plugin but I just have one question. I’m currently using the “Select Draw Mode” workflow for both polygon and none but is there a way to change the cursor? The cursor can sometimes be indistinguishable when setting the map view to satellite. Thank you
I’ll have a look for you. It is possible to change the cursor but I’m not sure if Google override it when the drawing modes change. Leave it with me and I’ll get back to you soon.
Hey @pork1977gm I am having an issue with an event of clicking a marker on a map and trying to get it to do something. My map is displaying addresses for a data type of “Job”. When I click on the map market the info box appears and shows some details of that job, which is great. But I also want to give the user a way to “select” this job by clicking on the maker. Perhaps have it add that “Job” to a list of jobs in a state on the page. Is that possible?
When you add the markers, do you set the marker ID to the unique ID of your database entry? If you do that, then inside the marker has clicked event, you should be able to reference “this marker’s Id” and use that within the constraint on a search. I think that should work anyway.
Try putting a condition on the searchBox that makes it visible when the map state called “is ready” is yes. I think the issue here is that when the searchBox loads before the map, it forces Bubble to load their version of the Maps API script before the plugin does. Make the searchBox not visible to begin with.
Well, to load a KML file and the data contained within it onto the map, you can run the “Add KML/KMZ data” action. That will draw whatever shapes are in it onto the map. The KML file needs to properly formatted for it to work. If you run into any errors, let me know.
Hey @pork1977gm, is there a way to encode the polygon coordinates into a JSON query string? I am not sure if I would need the plugin to do this or if I just need to do it within a workflow.
The API I am working with needs the polygon coordinates as pairs (with the first and last pair being the same to show its closed (I believe the coordinates already have the same first and last points, right?)
I see, yep that can done. I’m not at the laptop right now but just have a look to see if ai’ve added an “encode” action. If not, when I’m back at the laptop next, I’ll add it for you or figure out best way to deal with it.
There’s a state called “Encoded shape coordinates”, can you try that and see if the API you’re dealing with likes it.
It’s populated with polylines/polygons only and gets it’s value whenever those shapes are drawn or changed. I know some services want their pairs of coordinates as the longitude value first followed by the latitude, so I may need to add an option to reverse it if it doesn’t work as expected. It looks like this is the case for you.
I used to set the polygon coordinates as closed shapes (so last pair being the same as the first pair) but it caused a few issues with other areas in the plugin, so that’s not the case anymore. You can probably just append the first item to the end though if you take the polygon coordinates from the ‘Polygon coordinates’ state instead of using the ‘Drawing polygon coordinates’ state.
Update:
I’ve just added another action for you called “Encode shape” (update the plugin to see it). If needed, pass the ‘Polygon coordinates’ state to it and select the reverse coordinates option as shown below and hopefully that’ll sort you out.
I’ve just pushed another update with an event called: ‘shape_encoded’ added. That now triggers after the encode shape action completes. Inside the event, reference the ‘encoded shape coordinates’. You’ll have to split your workflows so everything up until the action runs in one, then everything after that inside the event so you can safely get the state’s value.