I'm trying to use a program that loads coordinates in EPSG:4326 format and plots on a map. The problem is that my coordinates are in EPSG:3006.
Is there any function to convert one projection in OpenLayers to another EPSG?
The better way to do this is to use proj4js library here, it is simple and you can add custom projections if you want.
Below you can see how it works:
var SourceProjection= new Proj4js.Proj('EPSG:4326');
var DestinationProjections= new Proj4js.Proj('EPSG:3006');
var Point = new Proj4js.Point(longitude, latitude);
Proj4js.transform(FirstProjection, SecondProjections, ne);
Or if you want to do it from openlayers you can use the "transform" function of geometry, here is a custom function that I use:
function TransformGeometry(geometry, SourceProj, DestProj) {
geometry.transform(
new OpenLayers.Projection(SourceProj),
new OpenLayers.Projection(DestProj));
return geometry;
}
In any case you have to declare proj4js in HTML tag in order to use a "long list" of projections (including here and custom projections you create).
Related
I'm trying to access a map column type using Astyanax.
From the examples I've taken the following. I'm looping the rows and can get the data from all the columns except the column storename which has datatype MAP. I assume I need to loop over the elements of the map to get the data into my object but I can't figure out how to do get the map data from the column.
I'm trying column.getValue and have tried getByteBuffer but can't get either to work. I can get a column object and I see there is a ColumnMap interface but I can't figure out how to get the data into an object that extends or uses it. I also see a MapSerializer interfaces but not sure how to implement that either...
List<Store> stores = new ArrayList<Store>();
for (Row<Integer, String> row : result.getResult().getRows()) {
Store store = new Store();
ColumnList<String> columns = row.getColumns();
store.setStoreID(columns.getStringValue("store_id", null));
store.setShopName(columns.getStringValue("shopname", null));
// lost trying to get the columns Map data here
// should I loop the map or pass the data straight to my store object as a map?
// How do I access the map data in this column?
for ( Map<String, String> map : columns.getValue("storename", imap, result).getResult() )
{
store.setStoreNames( "lang", "storename");
}
stores.add(store);
}
I'm a bit confused with getValue() as it takes a Serializer as it's 2nd argument and a default as it's 3rd. How do I pass the MapSerializer in as the 2nd argument or should I even be using getValue() method? Is the default a key value from the Map? If I want to return all values in the map what then? Thanks.
In the end this worked for me. And I was able to loop through the entries in the Map using the technique provided for looping maps here.
Map<String, String> map = columns.getValue("storename",
new MapSerializer<String, String>(UTF8Type.instance, UTF8Type.instance)
, new HashMap<String ,String>());
I have the following Bing Map v7: http://new.piperrealtycompany.com/temp/test2.cfm?city=fenton
In which I have a set of pushpins, with InfoBoxes associated with each one.
I'd have a list of corresponding links that are outside if the map.
I need the links in the list to open the corresponding InfoBoxes in the map and rolling over pushpins to highlight the corresponding link in list.
I'm trying to achieve something like this! http://www.zillow.com/flint-township-mi/
.
How can this be done?
This is fairly easy to do. First you need to add a unique value to each pushpin as you add it to the map. For example:
var pin = new Microsoft.Maps.Pushpin(map.getCenter());
pin.MyPinID = 1234;
map.entities.push(pin);
Since you are using JavaScript it is easy to add custom properties to classes. If you specify a unique value for each pushpin you can then later loop through all the shapes on the map and look for this value. You can then take this value and link it to your list item. You can do this in a couple of different ways. One method is to specify it in the rel tag of the item. Another method is to pass the value into the item's click event like so:
Link to pushpin
You can then create a method that loops through the shapes like so:
function FindPushpin(id){
var cnt = map.entities.getLength();
var pin, temp;
for(var I = 0; I< cnt; I++){
temp = map.entities.get(I);
if(temp.MyPinID && temp.MyPinID == id){
pin = temp;
break;
}
}
if(pin){
//you found the relative pin
}
}
So my problem seems to be simple but for the love of god i cant figure it out. So i am asking for your help. I have a simple list in a mobile application containing shops. I want to short them by distance from the center of my map.
It seems like i need a custom sorting function but im not sure on whati have to do in it.
i am using
testDist.setLatLng(propertyList.selectedItem.lat,propertyList.selectedItem.lng);
dist.text=""+GeodesicCalculatorUtil.calculateGeodesicDistance(FlexGlobals.topLevelApplication.currentLatLng2,testDist,DistanceUnits.KILOMETERS)
to get the distance for a shop and i have to compare it with the next one. however i cant figure out how to do it in the comparing function. I would be glad if anyone can help me.
As this seems to be a common problem for people using MapQuest as their mapping system, i provide my solution for sorting the custom POIs by distance to any list. This is a solution for mobile applications and this is the reason im using lists over datagrid.
protected function sort_clickHandler():void
{
var dataSortField:SortField = new SortField();
dataSortField.numeric = true;
/* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
var numericDataSort:Sort = new Sort();
numericDataSort.compareFunction=sortFunction;
/* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */
getAllMarkersResult.lastResult.sort = numericDataSort;
getAllMarkersResult.lastResult.refresh();
}
private function sortFunction(a:Object, b:Object, array:Array = null):int
{
var aPoi:LatLng = new LatLng(a.lat,a.lng);
var bPoi:LatLng = new LatLng(b.lat,b.lng);
var i:Number=GeodesicCalculatorUtil.calculateGeodesicDistance(FlexGlobals.topLevelApplication.currentLatLng2,aPoi,DistanceUnits.KILOMETERS);
var j:Number=GeodesicCalculatorUtil.calculateGeodesicDistance(FlexGlobals.topLevelApplication.currentLatLng2,bPoi,DistanceUnits.KILOMETERS);
return ObjectUtil.numericCompare(i, j);
}
I have some values stores in my model. I need to create a copy of those values, make some changes, and then output those changes without affecting the model values.
var my_source:Array = model.something.source
var output:Array = new Array();
for each (var vo:my_vo in my_source) {
if (vo.id == 1) {
vo.name = 'Foo';
output.push(vo);
}
else if (vo.id == 21) {
vo.name = 'Bar';
output.push(vo);
}
}
return output;
So, this works fine, except that any changes that are made when looping through my_source also seems to affect model.something. Why do changes to the my_source array affect the model? How do I prevent this from happening?
I've mentioned how to do this in my blog, but short answer is use ObjectUtil.copy(). What you're trying to do isn't copying since Flash uses reference based objects, so you're only copying the reference to the other array. By using ObjectUtil.copy(), you're doing what's called a 'deep copy' which is actually recreates the object in a new memory location.
You are dealing with references to data, not copies of data. This is how ActionScript-3 (and many other languages) works.
When you create the my_source variable, you are creating a reference to model.something.source, which also includes all of the references to your model objects. Further, when you loop through the my_vo objects, you are also getting a reference to these objects. This means that if you make changes to the object in this loop, you are making changes to the objects in the model.
How do you fix this? Inside your loop, you will need to make a copy of your object. I don't know what my_vo looks like, but if you have any other objects in that object tree, they would be references as well, which would probably require a "deep copy" to achieve what you want.
The easiest way (but usually not the most efficient way) to achieve a "deep copy" is to serialize and de-serialze. One way to achieve this:
function deepCopy(source:Object):* {
var serializer:ByteArray = new ByteArray();
serializer.writeObject(source);
serializer.position = 0;
return serializer.readObject();
}
Then, in your loop, you can make your copy of the data:
for each(var vo:my_vo in my_source) {
var copy:my_vo = deepCopy(vo);
// act on copy instead of vo
}
LinkeSetFx has its own CollectionEvent, but I don't know how to map the LinkedSetFx event to mx.events.collectionEvent(I want use it in ComboBox). LinkedSetFx is in AS3Commons-collection framework.Here is the url, choose the as3commons-collections-1.0.0.zip, you'll find LinkedSetFx in src\org\as3commons\collections\fx
Look at example from package.
var theSet : LinkedSetFx = new LinkedSetFx();
theSet.addEventListener(CollectionEvent.COLLECTION_CHANGED, changedHandler);
Is this you looked for?