I wrote this code in client side and sent to a server for a emailing purpose.in that email the image is appear as broken image I want to draw a path on google static map.here is the code I used.
<img src = "http://maps.googleapis.com/maps/api/staticmap?size=400x400&path=weight:3%7Ccolor:orange%7Cenc:'+polyline+'" />
polyline I created this way
var polyline;
var points = new Array();
for(var i=0; i<googleRoute.getVertexCount(); i++)
{
points[i] = new GLatLng(googleRoute.getVertex(i).lng(),googleRoute.getVertex(i).lat());
}
polyline = new GPolyline(points, '#ff0000', 5, 0.7);
when I used this code it will not appear the image.I wrote this code in client side and sent to a server for a emailing purpose.in that email the image is appear as broken image are there any wrong with my code?
when distance between two cities grows, the polyline variable will include lot of Glatlang values. so it causes to exceed the url character limit (What is the character limit on URL).
we can't send long url that exceed the charcter limit using ajax request. that's why I got that broken image.
As the solution I ignored intermediate Glatlang values by incrementing the for loop with skipping values. Therefore the polyline can be accepted for zoomed out maps.
If you have an array of points you can simply do:
$points = array('53.061969559518,-3.1661187796875', '52.647368106972,-2.6806604056641');
$pointsUrl = "";
for($i=0; $i<count($points); $i++) {
$pointsUrl .= '%7C'.$points[$i];
}
echo '<img src="http://maps.googleapis.com/maps/api/staticmap?path=color:0x0000ff%7Cweight:5'.$pointsUrl.'&size=270x256&maptype=roadmap&sensor=false" />';
Related
I know this kind of topic has been asked several times but non of the answers that I had found had worked with my javascript code. Everything in my page is fine. The web page that I have is about shopping list but not including the product name because there's no space in the web page for that, just for the price and tax, a calculator and to be used in a cell phone because is the cell phone the device that you can use in a supermarket. You make the price additions on the left column and write down the taxes in the right column. The total price is displayed in a <div> that is at the top of the page says 0 in red color. Like I expressed before, everything in the page is fine, is just that I want that <div> to display only 2 decimal digits after whole numbers. Let say you type: 4.65 in one of the textboxes on the left column because that's the product price and .28 on the right column because that is the tax. (Now in FL tax is .07) So, the total instead of showing up 4.93 it shows 4.930000000000001 and that's annoying for me. The same thing also happens in the calculator but that's fine for me.
The shopping list web page is: https://keilita.neocities.org/shop-calc.htm Thank you.
The problem lies in the fact that floating point numbers are actually approximations (except in those cases when they're multiples of negative powers of two, e.g., .75, .125 and the like). You should be able to do something like total.toFixed(2) to get the desired result (note that you'd also need this for cases like 3.10 to display correctly).
<script language="javascript">
function bindFunctions() {
var input = document.getElementsByTagName("input");
for(var i=0; i<input.length;i++){
if(input[i].type == "number"){
input[i].onblur = onBlurFunction;
}
if(input[i].type == "submit"){
input[i].onclick = onClickFunction;
}
}
}
bindFunctions();
function onBlurFunction(){
var ttl=0;
var input = document.getElementsByTagName("input");
for(var i=0; i<input.length;i++){
if(input[i].type == "number"){
ttl += Number(input[i].value);
}
}
document.getElementById("totales").innerHTML=ttl;
}
function onClickFunction(){
var inputHolder = document.getElementById('input-holder');
var input = document.createElement('input');
var br = document.createElement("br");
input.type = "number";
inputHolder.appendChild(input);
inputHolder.appendChild(br);
bindFunctions();
}
</script>
I am trying to make moving cars on MapBox using new promising GL Symbol layer/source. It looks very nice both on android and ios, but I faced with two impossibilities.
Symbols are always clustering. setIconAllowOverlap() and setIconIgnorePlacement() don't help: on some zoom it WILL be clustered. On both platforms.
How can I disable symbols clustering completely?
UPDATE: the code and even fast solution! (possibly bug? see comment at withTextField)
in onStyleLoaded():
...
carManager = new SymbolManager(mapView, mapboxMap, style);
carManager.setIconAllowOverlap(true);//doesn't help
carManager.setIconIgnorePlacement(true);//doesn't help
...
in drawCarFunction():
...
SymbolOptions carOptions = new SymbolOptions()
.withLatLng(latLng)
.withIconImage(carPlate)
//.withTextField(carPlate) //!!!! here it will cluster if text exists, and will NOT - without any text
;
Symbol car= carManager.create(carOptions);
carSymbols.add(car);
...
Next question:
On Android we have symbolManager.addClickListener() , but how could I catch a click on iOS? I know I can catch the tap, calculate nearest marker etc but
How to get symbol click simpler in swift?
In Moving cars task I should enumerate existing cars, move running, add newest. Where should I store cars IDs to get it later on next move? Where are no even symbol.setTag() option... Storing IDs in snippet (as on GMaps) is not that choice I expected from MapBox. Sure, I can make an array of pairs "car ID = symbol ID", but
How to store my own UID in the symbol?
UPDATE: the code. Note the comment near getTag()
void moveExistingCarOrAddNew(int carId, LatLng newLocation){
for (int i = 0; i < carManager.getAnnotations().size(); i++) {
if (carManager.getAnnotations().get(i).getTag()==carId){ //but no getTag() here, I should fit data into text fields
car.setLatLng(newLocation); //move!
} else {
...//create new marker as shown above }
}
}
}
Another developer created our original map but I'm tasked with making some changes. One of these is making sure the activated marker is brought to the front when clicked on (where it is partially overlapped by other markers).
The developers have used mapbox 2.2.2.
I have looked at leafletjs's docs, have followed some instructions on other posted solutions (e.g. solution one and solution two). Neither of these makes any difference.
Examining the marker in Chrome's console I can see the value of options.zIndexOffset is being set (10000 in my test case). I've even set _zIndex to an artificially high value and can see that reflected in the marker's data structure. But visually nothing is changing.
This is how the map is set up initially. All features are from a single geojson feed:
L.mapbox.accessToken = '<access token here>';
var map = L.mapbox.map('map', 'map.id', {
}).setView([37.8, -96], 3);
var jsonFeed, jsonFeedURL;
var featureLayer = L.mapbox.featureLayer()
.addTo(map)
.setFilter(function (f) {
return false;
});
$.getJSON(jsonFeedURL, function (json) {
jsonFeed = json;
jsonFeedOld = json;
// Load all the map features from our json file
featureLayer.setGeoJSON(jsonFeed);
}).done(function(e) {
// Once the json feed has loaded via AJAX, check to see if
// we should show a default view
mapControl.activateInitialItem();
});
Below is a snippet of how I had tried setting values to change the z-index. When a visual marker on the featureLayer is clicked, 'activateMarker' is called:
featureLayer.on('click', function (e) {
mapControl.activateMarker(e);
});
The GEOjson feed has urls for the icons to show, and the active marker icon is switched to an alternative version (which is also larger). When the active feature is a single Point I've tried to set values for the marker (lines commented out, some of the various things I've tried!)
activateMarker: function (e) {
var marker = e.layer;
var feature = e.layer.feature;
this.resetMarkers();
if (feature.properties.hasOwnProperty('icon')) {
feature.properties.icon['oldIcon'] = feature.properties.icon['iconUrl'];
feature.properties.icon['iconUrl'] = feature.properties.icon['iconActive'];
feature.properties.icon['oldIconSize'] = feature.properties.icon['iconSize'];
feature.properties.icon['iconSize'] = feature.properties.icon['iconSizeActive'];
}
if (feature.geometry.type == 'Point') {
marker.setZIndexOffset(10001);
marker.addTo(featureLayer);
}
//featureLayer.setGeoJSON(jsonFeed);
}
Any advice would be greatly appreciated! I'm at the point where I don't know what else to try (and that's saying something).
What probably happens is that you just flush your markers with the last call to .setGeoJSON():
If the layer already has features, they are replaced with the new features.
You correctly adjust the GeoJSON data related to your icon, so that when re-created, your featureLayer can use the new values to show a new icon (depending on how you configured featureLayer).
But anything you changed directly on the marker is lost, as the marker is removed and replaced by a new one, re-built from the GeoJSON data.
The "cleanest" way would probably be to avoid re-creating all features at every click.
Another way could be to also change something else in your GeoJSON data that tells featureLayer to build your new marker (through the pointToLayer option) with a different zIndexOffset option.
I am new to dashcode and trying to build a simple web app for iphone using it. My primary aim is to have a Rectangular List (I have used the "Rounded rectangle list"). It is a static list and has three rows. What I want is a website to open when user clicks on any of the row, and each row would have a different URL. I was able to add a Rounded rectangle list with three static rows like
The object ID is "list"
Row 1-- Label- "Gift Cards" , Value - "http://www.abcxyz.com/giftcard"
Row 2-- Label- "Toys" , Value - "http://www.abcxyz.com/toys"
Row 3-- Label- "Bikes" , Value - "http://www.abcxyz.com/bikes"
i added onclick even to call a java script function like below
function myButtonPressHandler(event)
{
var websiteURL = "http://www.abcxyz.com/giftcard";
location = websiteURL;
}
the above code opens the same URL "http://www.abcxyz.com/giftcard" when the user clicks on any of the three buttons, but what I want is to fetch the value of each child node (which would be their respective URLs) at runtime and open it using location = WebsiteURL something like below (did'nt work for me :( -
function myButtonPressHandler(event)
{
var websiteURL = document.getElementById("list").children;
var WebURL = websiteURL[???].value;
location = WebURL;
}
Any help would be appreciated.
Thanks
OK ... so figured out my own answer. The Rounded Rectangular list is actually a multidimensional array. so to get the value of each of the rows i.e. the Http URLs and open them on the browser when the rows were touched/tapped/pressed is as below.
function buttonpresshandler(event)
{
// Insert Code Here
var list = document.getElementById("list").object;
var selectedObjects = list.selectedObjects();
//Open webpage with the value of each label
location = selectedObjects[0][1];
}
Hurray!
I'm using the GMaps, Location and User locations module on my Drupal site. I would like to have a map which can display the "coverage" of my users. The coverage radius is stored in a custom content type with reference to the user.
How is it possible to display users with only their coverage circle on a map? I saw a display type like this when playing with the GMap macros, so I think it would be possible to use GMaps that way.
I suppose most likely this isn't supported out-of-the-box with the GMap module. Anyway, I would be really glad if anybody could point me into the right direction...
I've managed to do this after all with the help of the Hungarian community. (I would be happy to link the original thread, but it seems it got deleted.)
Basically the "trick" was to make a little custom module with a hook:
function MODULENAME_preprocess_gmap_view_gmap(&$vars) {
if ( $vars['view']->name == "my_gmap_view" ) {
$map_object = $vars['map_object'];
$map_object['id'] = 'my_view_id';
foreach ($vars['view']->result as $key => $row) {
$shapes[$key]['type'] = 'circle';
// we have a profile field for the radius, but it could be anything...
$shapes[$key]['radius'] = $row->profile_values_profile_radius_value;
// center the circles on the coord
$shapes[$key]['center'][0] = $row->location_latitude;
$shapes[$key]['center'][1]= $row->location_longitude;
}
// we don't need any markers, just the circles
$map_object['markers'] = NULL;
$map_object['shapes'] = $shapes;
$vars['map'] = theme('gmap', array('#settings' => $map_object));
}
}