Imrana
New Members-
Posts
9 -
Joined
-
Last visited
Imrana's Achievements
Newbie (1/5)
0
Reputation
-
Hi all, Hope you are well. Thank you for having a look at my post. I searched google and cannot find much help on what Im looking for. I would like to draw a textarea on google maps which can be edited, just like you can add/edit polygon, polyline , circle, rectangle using the google maps drawing tools. Is this possible? Please point me in the right direction. This is the closest thing I can find but I need to be able to draw and edit them like with google maps drawing tools, http://www.geocodezip.com/ParkerPalmSprings.html Thank you. Kind regards, Imran
- 1 reply
-
- google maps api
- google maps overlay
-
(and 1 more)
Tagged with:
-
Ive got it working, it turns out you can add a custom property, see code below: var dbpolygon=new google.maps.Polygon({ id: polygon[0].id, /*** custom property*****/ path: points, strokeColor: polygon[0].type, strokeOpacity: 0.4, strokeWeight: 2, fillColor: polygon[0].type, fillOpacity: 0.4, editable: false }); I can check to see if this property exists, this is the code if (typeof selectedShape.get('id') !== 'undefined') { //polygon exists }
- 7 replies
-
- google maps api
- polygon
-
(and 2 more)
Tagged with:
-
Hi all, I would like you thank everyone for their help. Thank you Kicken for your examples that really helped me picture how to read the data back. I just need to draw the shapes and display them. No searching will be needed but I will store the points separately in another table as thats a better design as suggested by everyone. One other thing I need to do it edit the polygon once I get the data from the database and display it. Is there a way of adding a reference to the polygon - adding the primary key from my database table? This way I can check if the shape exists and I need to update instead of insert. Here is my code to assign that created the shape: var dbpolygon=new google.maps.Polygon({ path: points, strokeColor: red, strokeOpacity: 0.4, strokeWeight: 2, fillColor: red, fillOpacity: 0.4, editable: false }); dbpolygon.setMap(map); google.maps.event.addListener(dbpolygon, 'click', function() { setSelection(this); }); I dont know how I would add a unique reference? Thank you.
- 7 replies
-
- google maps api
- polygon
-
(and 2 more)
Tagged with:
-
Google Maps - Add click listener to each polygon
Imrana replied to Imrana's topic in Javascript Help
Hi Kicken, Thank you so much for helping me with this. using the 'this' keyword has resolved my problem. I will through the link you have suggested and have a look at the factory pattern. Thank you again Imran -
Hi all, I am working on a webapplication. I have a google map, where I add polygons from an array. I loop through that array and add the polygons to the map. I also need to add an 'click' event listener to the polygon to make it editable. This is what I am doing: var polygons = data; // array holding json objects. Each object is a polyline for(var i=0; i<polygons.length; i++) { var polygon = polygons[i]; var points = []; for(var j=0; j<polygon[1].points.length; j++) { var item = new google.maps.LatLng(polygon[1].points[j].lat, polygon[1].points[j].lng); points.push(item); } var dbpolygon=new google.maps.Polygon({ path: points, strokeColor: polygon[0].type, strokeOpacity: 0.4, strokeWeight: 2, fillColor: polygon[0].type, fillOpacity: 0.4, editable: false }); dbpolygon.setMap(map); google.maps.event.addListener(dbpolygon, 'click', function() { setSelection(dbpolygon); }); } Problem The polygons are all drawing correctly. However the problem is that when I try to click on a polygon it always selects the last index. it is like it is only clicking on the last polygon added. I think when I add a new listener it overrides the old one. How can I add a listener for each polygon added in order to alert the correct index? Thank you
-
Hi all, Thank you for viewing my post. In my application I allow users to draw shapes on google maps using google maps api v3. I dont know how to store the polygons coordinates in MySQL? Please help. I was thinking should I store each point as a seperate row or store the whole polygon in one row as json? Is there a better way? Kind regards, Imran
- 7 replies
-
- google maps api
- polygon
-
(and 2 more)
Tagged with:
-
Hi all, Thank you for viewing my post. In my application I allow users to draw shapes on google maps using google maps api v3. I dont know how to store the polygons in MySQL? Im new to google maps api and dont have a clue. Please help. I was thinking should I store each point seperately in a database field or store the whole polygon as json? This is what I have so far. I have created a json object that stores all the verticles in a list. I was thinking of saving this whole json in one database field? This is the code used to contruct the array: var vertices = selectedShape.getPath(); // MVCArray var pointsArray = []; //list of polyline points for (var i =0; i < vertices.getLength(); i++) { var xy = vertices.getAt(i); //LatLang for a polyline var item = { "lat" : xy.lat(), "lng":xy.lng()}; pointsArray.push(item); } var polygon = {"points" : pointsArray}; This is the constructed json result: {"points": [ {"lat": 51.51814351604911, "lng": -0.14479637145996094 }, { "lat": 51.51830374452608, "lng": -0.13861656188964844}, { "lat": 51.516194024429446, "lng": -0.13968944549560547} ]} Should I have the whole thing in one field? Is it better to save each vertices (lat and lng) in a seperate row, so for the above polygon there will be 3 rows? Kind regards, Imran
- 7 replies
-
- google maps api
- polygon
-
(and 2 more)
Tagged with:
-
Thank you JD, thats solved my problem. My apologies for posting in the wrong place, I see there is a JavaScript section at phpFreaks. Thanks again
-
Hi all, Thank you for taking your time to read my post. I am using php, ajax(jQuery) and json to save data to a database. Here is my JavaScript code: <script> var jsonList = [ {"type":"sw"}, {"points":[ {"lat":51.51429786349476,"lng":-0.14556884765625}, {"lat":51.51435127755925,"lng":-0.1393890380859375}, {"lat":51.51221466612502,"lng":-0.14277935028076172} ]} ]; $.post("save.inc.php", jsonList, function(res) { alert(res); } </script> I have created a javascript array which holds two json objects. I want to pass this to a php file. The php file needs to save the two json objects seperately. I dont know how to access the data when its gets sent to php. I am new to ajax and json, I have looked for hours on google and cannot find how to read multidimensional $_POST array. Please help. This is what I tried to access the json objects but it does not work. <?php //This is save.inc.php $type = $_POST[0]; $points = $_POST[1]; echo(json_encode($type)); ?> kind regards, Imran