Skip to content

Instantly share code, notes, and snippets.

@swingley
Created July 26, 2013 16:49
Show Gist options
  • Save swingley/6090402 to your computer and use it in GitHub Desktop.
Save swingley/6090402 to your computer and use it in GitHub Desktop.
get simple renderer from a map on arcgis.com, use it to symbolize map click points
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<link rel="stylesheet" href="//js.arcgis.com/3.6/js/esri/css/esri.css">
<style>
html, body, #map {
height: 100%; width: 100%; margin: 0; padding: 0;
}
</style>
<script src="//js.arcgis.com/3.6/"></script>
<script>
var map;
require([
"esri/map",
"esri/request",
"esri/renderers/SimpleRenderer",
"esri/graphic",
"dojo/domReady!"
], function(
Map, esriRequqest, SimpleRenderer, Graphic
) {
map = new Map("map", {
basemap: "streets",
center: [ 19.291, 48.343 ],
zoom: 4
});
var renderer;
// go get data from an arcgis.com map
esriRequqest({
url: "http://www.arcgis.com/sharing/rest/content/items/ce4cbe1d06e2484284ffd692dfa62545/data",
content: {
f: "json"
},
callbackParamName: "callback"
}).then(
function(data) {
var simple = data.operationalLayers[0].featureCollection.layers[1].layerDefinition.drawingInfo.renderer;
console.log("simple", simple);
renderer = new SimpleRenderer(simple);
console.log("renderer", renderer);
map.graphics.setRenderer(renderer);
map.on("click", function(e) {
console.log("click");
map.graphics.add(new Graphic(e.mapPoint));
console.log("added");
});
},
function(error) {
console.log("error", error);
}
);
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment