Google Maps Save Polygon and points in MySQL using PHP

后端 未结 3 1135
遥遥无期
遥遥无期 2021-01-02 07:57

Right now I have an application that allows users to draw a polygon on google maps. I need to save this polygon using PHP and MySQL but I\'m unsure of best practices.

相关标签:
3条回答
  • 2021-01-02 08:36

    You can also use : google.maps.geometry.encoding to encode/compress paths

    http://code.google.com/intl/fr/apis/maps/documentation/utilities/polylinealgorithm.html

    I once used this to save in database thousands of directions and it is quite convenient.

    0 讨论(0)
  • 2021-01-02 08:54

    Take the time to familiarize yourself with the spatial extensions as they will help you accomplish tasks down the road and not only for this project.

    0 讨论(0)
  • 2021-01-02 08:56

    It's best to think of your usage scenarios when planning out your storage layer.

    This will help you figure out which queries you'll want your persistence layer to optimize for.

    If you're going to handle lot's of queries like, "Find me all objects within this space". You may want to look at using the spatial extensions.

    However, if most of the time you're simply drawing an object with a given id, simply saving the polygons as a json blob in the DB may do.

    CREATE TABLE Polygons ( polygon_id int not null, vertices_json varchar(4096) )

    0 讨论(0)
提交回复
热议问题