POST
|
Tim, we would like to display the driving time to the point, not the directions... Going back to the snippet I provided, we get the following error: Uncaught TypeError: object is not a function
... View more
10-07-2014
11:05 AM
|
0
|
0
|
768
|
POST
|
Hello again Tim. We are just hoping to show the distance from where the person fired an event in comparison to the location where he should be. So we don't really need directions, just the distance measurements...
... View more
10-07-2014
10:19 AM
|
0
|
2
|
768
|
POST
|
We are trying to calculate the distance between two markers plotted in our map. We tried using the Polyline object but that returns a straight line from one marker to the other, not the real distance, or route. Is there a way to do so? We are using the following function...
function sitepins(val) {
var iconPath = "M15.834,29.084 15.834,16.166 2.917,16.166 29.083,2.917z";
var initColor = "#005CE6";
var ind=0;
for (var index = 0; index < arr.length; index++){
if (arr[index]==val){
ind =index;
}
Lon = arr[ind+1];
Lat = arr[ind+2];
Lon1 = arr[ind+4];
Lat1 = arr[ind+5];
//var polylineJson = {"paths":[[[-122.68,45.53], [-122.58,45.55]]]};
var singlePathPolyline = new Polyline([[-50, 0], [-120, -20], [-130, 0]]);
//var polyline = new Polyline(polylineJson);
var lengths = geodesicUtils.geodesicLengths([singlePathPolyline], Units.KILOMETERS);
console.log(lengths);
}
... View more
10-07-2014
09:36 AM
|
0
|
6
|
1698
|
POST
|
Tim, we tried all of the options but still did not get it to work. We ended up returning a string and trimming it with delimeters to isolate the value we needed in a variable. Thank you for the assistance.
... View more
10-07-2014
09:30 AM
|
0
|
0
|
176
|
POST
|
Tim, the capitalization was a typo when typing the question. In the code it was as you suggested but the error remained. Unfortunately I cannot share the application since it is internal to the company, but here is a code snippet.
<script type="text/javascript">
$( document ).bind( "ready", function( ) {
$( document ).delegate( "path", "click", function( ) {
console.log( $( this ) );
} );
} );
require(["esri/map", "esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol", "esri/graphic", "dojo/_base/array", "dojo/dom-style", "dojox/widget/ColorPicker", "esri/InfoTemplate", "esri/Color", "dojo/dom", "dojo/domReady!"],
function( Map, Point,SimpleMarkerSymbol, Graphic, arrayUtils, domStyle, ColorPicker, InfoTemplate, Color, dom) {
map = new Map("mapDiv", {
center : [-98.35, 35.50],
zoom : 5,
basemap : "gray"
//basemap types: "satellite", "hybrid", "topo", "gray", "oceans", "osm", "national-geographic"
} );
map.on( "load", pinMaps);
function pinMaps( ) {
var iconPath = "M16,3.5c-4.142,0-7.5,3.358-7.5,7.5c0,4.143,7.5,18.121,7.5,18.121S23.5,15.143,23.5,11C23.5,6.858,20.143,3.5,16,3.5z M16,14.584c-1.979,0-3.584-1.604-3.584-3.584S14.021,7.416,16,7.416S19.584,9.021,19.584,11S17.979,14.584,16,14.584z";
var infoContent = "<b>Id</b>: ${Id} <br /><b>x</b>: ${x}";
var infoTemplate = new InfoTemplate(" Information",infoContent);
$.post( '{{ path( 'points' ) }}', {}, function( r ) {
arrayUtils.forEach( r.points, function( point ) {
if (point.x==1) {
var initColor = "#CF3A3A";
}
else {
var initColor = "#FF9900";
}
var attr = {"Id":point.id,"x":point.x};
var graphic = new Graphic( new Point( point.coords ), createSymbol( iconPath, initColor ), attr, infoTemplate);
map.graphics.add( graphic );
map.graphics.on("click",function(evt)
{
var str = evt.graphic.attributes.id;
console.log(str+"end");
});
} );
}, 'json' );
}
function createSymbol( path, color ) {
var markerSymbol = new esri.symbol.SimpleMarkerSymbol( );
markerSymbol.setPath( path );
markerSymbol.setColor( new dojo.Color( color ) );
markerSymbol.setOutline( null );
return markerSymbol;
}
} );
</script>
<?php
class DefaultController extends Controller {
public function indexAction( ) {
return $this->render( 'MapBundle:default:test.html.twig', array( "name" => "Map", "title" => "Map", "subTitle" => "Test" ) );
}
public function pointAction( ) {
$points = array( );
$conn = DriverManager::getConnection( array(
'driver' => '___',
'dbname' => '___',
'user' => $this->container->getParameter( 'database_user' ),
'password' => $this->container->getParameter( 'database_password' )
) );
$stmt = $conn->prepare( "SELECT * FROM test");
$stmt->execute( );
while( $row = $stmt->fetch( ) ) {
$points[] = array( "id" => $row['markerID'],
"x" => $row['x'],
"pincoords" => array( $row[ 'siteLon' ], $row[ 'siteLat' ] ),
"coords" => array( $row[ 'pinLon' ], $row[ 'pinLat' ] ) );
}
return new JsonResponse( array(
"points" => $points
) );
}
}
... View more
10-06-2014
09:02 AM
|
0
|
2
|
176
|
POST
|
Tim, this time it did not work. The errors are below. var str = evt.graphic.attributes.Id; -> Uncaught TypeError: Cannot read property 'id' of undefined var str = evt.graphic.attributes[0]; -> Undefined.
... View more
10-06-2014
08:35 AM
|
0
|
6
|
935
|
POST
|
Tim, Thank you for the suggestion. That solved the problem!! If I may ask one follow up question, now that we can retrieve just the string for the marker that is clicked, is it possible to access a specific element of that string? I.e. our string returns id and x. Is it possible to retrieve only the ID? Thank you
... View more
10-06-2014
08:19 AM
|
0
|
8
|
935
|
POST
|
Paul Crickard, one of the issues with splitting the string is that when we select a marker, instead only the information for the particular marker that was clicked, we get the information for all of the markers that are displayed on the map. Sorry if this is a trivial question, but we are new with ArcGIS and the API.
... View more
10-06-2014
08:02 AM
|
0
|
0
|
935
|
POST
|
We are trying to plot a point on map based on the click of a different marker, meaning we have two different sets of lat and long values. Once the map is loaded, we have all markers displayed, but when one marker is clicked, we should pin a new marker that contains the second location of the ID. To do so we are using the getContent() function, but once a marker is clicked, the function retrieves the all of the values in the view as a string, not just the values associated to the marker that is clicked. Is there a way to retrieve just the values that are clicked?
map.on( "load", pinMap);
function pinMap( ) {
var iconPath = "M16,3.5c-4.142,0-7.5,3.358-7.5,7.5c0,4.143,7.5,18.121,7.5,18.121S23.5,15.143,23.5,11C23.5,6.858,20.143,3.5,16,3.5z M16,14.584c-1.979,0-3.584-1.604-3.584-3.584S14.021,7.416,16,7.416S19.584,9.021,19.584,11S17.979,14.584,16,14.584z";
var infoContent = "<b>Id</b>: ${Id} <br /><b>x</b>: ${x}";
var infoTemplate = new InfoTemplate(" Information",infoContent);
$.post( '{{ path( 'points' ) }}', {}, function( r ) {
arrayUtils.forEach( r.points, function( point ) {
if (point.x==1) {
var initColor = "#CF3A3A";
}
else {
var initColor = "#FF9900";
}
var attr = {"Id":point.id,"x":point.x};
var graphic = new Graphic( new Point( point.coords ), createSymbol( iconPath, initColor ), attr, infoTemplate);
map.graphics.add( graphic );
map.graphics.on("click",function()
{
var str = graphic.getContent();
console.log(str);
});
} );
}, 'json' );
}
... View more
10-06-2014
07:18 AM
|
0
|
12
|
2039
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|