26/06/2014, 19:31
|
| | Fecha de Ingreso: enero-2012
Mensajes: 224
Antigüedad: 12 años, 10 meses Puntos: 1 | |
parsear json con jsonp hola estoy usando jsonp y en un ejemplo me funciona bien pero en otro no,
este esta ok
Código:
<script>
var map;
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 2,
center: new google.maps.LatLng(40,-187.3),
mapTypeId: google.maps.MapTypeId.TERRAIN
});
// Create a <script> tag and set the USGS URL as the source.
var script = document.createElement('script');
script.src = 'http://67.23.231.40/~bplus/brown%20plus%20joven/2/conectando.php';
document.getElementsByTagName('head')[0].appendChild(script);
}
// Loop through the results array and place a marker for each
// set of coordinates.
function jsoncallback(results){
for (var i = 0; i < results.length; i++) {
var earthquake = results[i];
var coords = earthquake.distrito;
var latLng = new google.maps.LatLng(earthquake.distrito);
var marker = new google.maps.Marker({
position: latLng,
map: map
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
para este json
Código:
eqfeed_callback({"type":"FeatureCollection","metadata":{"generated": 1403827457000,"url": "http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week","title": "USGS Magnitude 2.5+ Earthquakes, Past Week","subTitle": "Real-time, worldwide earthquake list for the past week", "cacheMaxAge": 60},"features":[
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
{ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
},
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
},
"properties": {
"prop0": "value0",
"prop1": {"this": "that"}
}
}
]
}
pero mi json es este
Código:
([{"id":"203","name":"ZUH","rubro":"42938985","direccion":"E. ADROGU? 1107 LOCAL 3","telefono":"","localidad":"ADROGUE","local":"ALMIRANTE BROWN","direccioncomp":"E. ADROGU? 1107 LOCAL 3 ADROGUE ALMIRANTE BROWN","distrito":"Not Found (try again, you may have done too many too fast)","direccioncompleta":"10% EN GENERAL EN EFECTIVO, EXCEPTO EN LIQUIDACI?N.","geo":"","descuento":"","latitud":null,"longitud":null},{"id":"202","name":"VIENTO ORIENTAL","rubro":"42142292","direccion":"PELLERANO 726","telefono":"","localidad":"ADROGUE","local":"ALMIRANTE BROWN","direccioncomp":"PELLERANO 726 ADROGUE ALMIRANTE BROWN","distrito":"-34.7988634,-58.3911604","direccioncompleta":"15%AL MEDIOD?A LOS LUNES, JUEVES Y VIERNES. 20% LOS MI?RCOLES TODO EL D?A. DTOS SOBRE PRECIO DE LISTA, NO ACUMULABLES CON OTRAS PROMOCIONES.","geo":"","descuento":"","latitud":null,"longitud":null}] )
|