POST
|
1. Define the polygon spatial reference before you add the ring 2. alert (thisLocs) right before you try to use it. My guess is this is a scoping issue and it is null try changing the line to on(map, "load", lang.hitch(this, function(){addGraphic();})); Hi Jeff, Many thanks to you for your reply. I've tried both the things i.e.: 1. Defining spatial reference before adding ring 2. placing alert(thisLocs) before its use, gives its proper value. Its not null. Secondly, I changed my code to on(map, "load", lang.hitch(this, function(){addGraphic();})); but, it doesn't call addGRaphic() function. Thanks, Dipti Sheth
... View more
04-28-2014
06:35 PM
|
0
|
0
|
273
|
POST
|
Hi Dipti, I worked up your code in a jsfiddle sample that appears to work using your variable defined as an array. http://jsfiddle.net/QAeHM/1/ The polygon seems to draw. Can you see where your code varies from mine? May be in the Load area. Rob Hi Robert, Many thanks for your reply. Yes, you are right, its load area where my code varies from yours. Its not working on my side. I replaced my code with yours, but I guess may be due to load part i.e. ready(function () { map.on("load", function (evt) { it is not working. Can you please tell me when ready() should be used? In my app, ESRI maps should be loaded on calling of function LoadEsriTrees(), when a dropdown button 'Load ESRI Maps' is clicked. Can you please guide me further how to modify it as per my code? Thanks a lot, Dipti Sheth
... View more
04-28-2014
10:20 AM
|
0
|
0
|
408
|
POST
|
Hi, Please find polygon code attached herewith. It works only with hard-coded data and not with data passed through db. Why so? Am I doing anything wrong or Is it a bug with ESRI map? I searched/googled a lot, even posted on forums 3 times, but didn't get any satisfactory reply. Please somebody look into this code and send me a sample of working code where data is passed through db, not hardcoded. Thanks, Dipti Sheth
... View more
04-28-2014
02:34 AM
|
0
|
5
|
1993
|
POST
|
Maybe you need to specify a spatial reference using the wkid of the basemap that you are using. Hi, Thanks for your replies. I've tried both the things i.e. adding web mercator as well as adding 'new polygon(thisLocs[0])' as thisLocs is an array. But, still it doesn't work. Please find the attached file containing complete code here. Please help me to find out the solution. Its really urgent. Thanks a lot, Dipti Sheth
... View more
04-26-2014
07:57 PM
|
0
|
0
|
408
|
POST
|
Hi, My polygon data is in following format coming from db var thisLocs = new Array(); var thisLocs = [[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]; If I hard-code this: var singleRingPolygon = new Polygon([[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]); var gra = new Graphic(singleRingPolygon, sfs); map.graphics.add(gra); It shows polygon. But, if I pass it as var singleRingPolygon = new Polygon(thisLocs); It does not show up polygon. Please any body guide me..why its happening so. I'm re-posting this question as I didn't get any positive answers yet. Thanks, Dipti Sheth
... View more
04-25-2014
10:11 AM
|
0
|
5
|
1952
|
POST
|
Can you post all of your current code where you get the polygon data from a db? Hi, following is my current code: var $mover = $('#thingtypecontent'); var polygonData = $mover.find('input#hdndata').val(); var check1 = (polygonData.indexOf("POLYGON ((") !== -1); if (check1 == true) polygonData = polygonData.replace('POLYGON ((', '['); var check2 = (polygonData.indexOf("))") !== -1); if (check2 == true) polygonData = polygonData.replace('))', ']'); polygonData = polygonData.replace(/,\s+/g, '],['); //create polygon data var coords = new Array(); var allLocs = new Array(); var anchorLat = null; var anchorLon = null; coords = polygonData.split(" "); var thisLocs = new Array(); var anchorCoord = null; if ((coords.length / 2) % 2) { anchorCoord = coords.length / 2 - 1; } else { anchorCoord = coords.length / 2; } for (k = 0; k <= coords.length - 1; k = k + 2) { var thisLoc = new esri.geometry.Point(coords , coords[k + 1]); thisLocs.push(thisLoc); allLocs.push(thisLoc); if (k == anchorCoord) { anchorLat = coords[k + 1]; anchorLon = coords ; } } var map; require([ "esri/map", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "esri/graphic", "esri/geometry/Polygon", "dojo/on", "dojo/dom", "dojo/domReady!" ], function ( Map, SimpleFillSymbol, SimpleLineSymbol, Color, Graphic, Polygon, on, dom ) { map = new Map("mapDiv", { center: [174.605369, -37.120276], zoom: 15, basemap: "streets" }); on(map, "load", addGraphic); var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]) ) function addGraphic() { // var singleRingPolygon = new Polygon([[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]); var singleRingPolygon = new Polygon(thisLocs); var gra = new Graphic(singleRingPolygon, sfs); map.graphics.add(gra); } });
... View more
04-23-2014
12:25 PM
|
0
|
0
|
562
|
POST
|
You will need to pass the coordinates as an array. See the following link. Create a new polygon by providing an array of geographic coordinate pairs. For a single ring polygon specify an array of coordinate pairs. For a multi-ring polygon specify an array of array coordinate pairs. Hi, I get coordinates from db and format that data it in the following form: [[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]) If I hardcode this value as: var singleRingPolygon = new Polygon([[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]); it works well and shows polygon. But..how to convert it to array...I tried many things...but still no positive result. I created array, pushed all values into array and then passed it to create polygon...still of no help. Please guide me in more detail. Thanks, Dipti Sheth
... View more
04-23-2014
11:18 AM
|
0
|
0
|
562
|
POST
|
Hi Dipti, Take a look at this example. This should get you going in the right direction. <!DOCTYPE html>
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css">
<style>
html, body, #mapDiv{
padding: 0;
margin: 0;
height: 100%;
}
</style>
<script src="http://js.arcgis.com/3.8/"></script>
<script>
var map;
require([
"esri/map",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"dojo/_base/Color",
"esri/graphic",
"esri/geometry/Polygon",
"dojo/on",
"dojo/dom",
"dojo/domReady!"
],
function(
Map, SimpleFillSymbol, SimpleLineSymbol, Color,
Graphic, Polygon,
on, dom
) {
map = new Map("mapDiv", {
center: [174.605369, -37.120276],
zoom: 15,
basemap: "streets"
});
on(map, "load", addGraphic);
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
)
function addGraphic(){
var singleRingPolygon = new Polygon([[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]);
var gra = new Graphic(singleRingPolygon, sfs);
map.graphics.add(gra);
}
});
</script>
</head>
<body class="claro">
<div id="mapDiv"></div>
</body>
</html> Hi, First of all really sorry for my late response. Thanks for your code..it really shows up polygon. But..next step is that this data comes from db, so when I store it in array or string and pass it to polygon as follows: var singleRingPolygon = new Polygon(thisLocs.toString()); it again doesn't show up anything. Please have a look at this and let me know...in which format coordinated data should be passed from db to show up polygon. Thanks a lot, Dipti Sheth
... View more
04-23-2014
03:30 AM
|
0
|
0
|
562
|
POST
|
Hi, Following is my code: function LoadEsriTrees() { var divEsriMap = $mover.find('div#mapDiv').attr('id'); require( ["esri/map", "esri/layers/GraphicsLayer", "dojo/_base/array", "esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol", "dojo/_base/Color", "esri/graphic", "esri/InfoTemplate", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/ImageParameters"], function (Map, GraphicsLayer, array, Point, SimpleMarkerSymbol, Color, Graphic, InfoTemplate, ArcGISDynamicMapServiceLayer, ImageParameters) { map = new Map(divEsriMap, { center: [174.605, -37.119], zoom: 15 }); //var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer", { id: 'basemap' }); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", { id: 'basemap' }); map.addLayer(basemap); //show polygon dojo.connect(map, 'onLoad', function () { // var myPolygon = new esri.geometry.Polygon(new esri.SpatialReference({ wkid: 4326 })); var myPolygon = new esri.geometry.Polygon([[174.605111568859, -37.119413675388707], [174.6051123299834, -37.119449718193458], [174.60515905129122, -37.119530204987136], [174.60540067619004, -37.119779304335452], [174.60554255499551, -37.120101860545844], [174.60568043759687, -37.120235191897571], [174.60572696965184, -37.1203066677341], [174.60572849253467, -37.120378753310746], [174.60570674933629, -37.120415100973361], [174.60560757225889, -37.120515590528086], [174.60554177129595, -37.120597601350227], [174.60549026791193, -37.120823630882519], [174.6054873903158, -37.121220253972716], [174.6055119446122, -37.122382633739591], [174.60513274122792, -37.119350295725816], [174.605111568859, -37.119413675388707]]); // map is in web mercator so transform the geometry // var poly_wm = esri.geometry.geographicToWebMercator(myPolygon); // var symbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID); var symbol = new esri.symbol.SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]) ); // polygonGraphic = new esri.Graphic(poly_wm, symbol); polygonGraphic = new esri.Graphic(myPolygon, symbol); map.graphics.add(polygonGraphic); }); } ); } Can any one please help me to locate polygon on the map? I don't know..where I'm getting wrong, its not showing up polygon on the map. Thanks, Dipti Sheth
... View more
04-21-2014
07:08 PM
|
0
|
6
|
768
|
POST
|
Hello Dipti, Please check this link contains example+source code.. Hope this will help you.. thanks... Hi sunilpalkar, First of all really sorry for the late reply. I checked the link and it passes data through a service layer, but in my case, data comes from sql db. So, it won't work. Anyways, really thankful to send me such a good post. Thanks, Dipti Sheth
... View more
04-03-2014
06:26 PM
|
0
|
0
|
338
|
POST
|
One thing that jumps out at me - your lat/long values need to be numbers instead of strings. Try entering your lat/longs as numbers in your "treePointInfo" array, or convert the lat/longs to numbers using "parseFloat" when you convert your array into a map. Hi tligon, Thanks for your reply. But, Its not working. I tried both the things i.e. I passed long/lat as number as well as while passing converted it to float, yet it does not work. Please provide me some working example of it, if you can. Thanks for your gesture, Dipti Sheth
... View more
04-02-2014
06:32 PM
|
0
|
0
|
338
|
POST
|
Hello, I've modified code for ESRI point clustering as per my need. I'm creating object of arrays and passing it as data to show point clustering on map. But, its not showing any results. Please look at the below code and tell me why it is not working. map.on("load", function () { // hide the popup's ZoomTo link as it doesn't make sense for cluster features domStyle.set(query("a.action.zoomTo")[0], "display", "none"); addClusters(); }); function addClusters() { var lat; var long; var treePointInfo = {}; var attributes; treePointInfo = [ { lat: "175.10345988912422", long: "-37.187682856475966", attributes: "" }, { lat: "175.10347539747", long: "-37.187835793400758", attributes: "" }, { lat: "175.10351267433421", long: "-37.18796130619176", attributes: "" } ]; treePointInfo.data = arrayUtils.map(treePointInfo, function (p) { var pointX = p.long; var pointY = p.lat; var att = p.attributes; return { "x": pointX, "y": pointY, "attributes": att }; }); // popupTemplate to work with attributes specific to this dataset var popupTemplate = PopupTemplate({ "title": "" }); // cluster layer that uses OpenLayers style clustering clusterLayer = new ClusterLayer({ "data": treePointInfo.data, "distance": 100, "id": "clusters", "labelColor": "#fff", "labelOffset": 10, "resolution": map.extent.getWidth() / map.width, "singleColor": "#888", "singleTemplate": popupTemplate }); var defaultSym = new esri.symbol.SimpleMarkerSymbol().setSize(4); var renderer = new esri.renderer.ClassBreaksRenderer(defaultSym, "clusterCount"); var picBaseUrl = "http://static.arcgis.com/images/Symbols/Shapes/"; var blue = new esri.symbol.PictureMarkerSymbol(picBaseUrl + "BluePin1LargeB.png", 32, 32).setOffset(0, 15); var green = new esri.symbol.PictureMarkerSymbol(picBaseUrl + "GreenPin1LargeB.png", 64, 64).setOffset(0, 15); var red = new esri.symbol.PictureMarkerSymbol(picBaseUrl + "RedPin1LargeB.png", 72, 72).setOffset(0, 15); renderer.addBreak(0, 2, blue); renderer.addBreak(2, 200, green); renderer.addBreak(200, 1001, red); clusterLayer.setRenderer(renderer); map.addLayer(clusterLayer); // close the info window when the map is clicked map.on("click", cleanUp); // close the info window when esc is pressed map.on("key-down", function (e) { if (e.keyCode === 27) { cleanUp(); } }); } Thanks, Dipti Sheth
... View more
04-01-2014
06:32 PM
|
0
|
4
|
471
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|